How to make a neural network go to a part / cframe? (idk how to train it or smth)

  1. What do you want to achieve? Keep it simple and clear!
    So how would i go about training a neural network to go to a part / cframe

  2. What is the issue? Include screenshots / videos if possible!
    The neural network is dumb…
    robloxapp-20240827-1827537.wmv (1.9 MB)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    No solutions on developer hub

-- This script is attached to a Part instance in the Workspace

local part = script.Parent

while true do
	task.wait(0.1)

	-- Variables --
	local i = {math.random(0, 1), math.random(0, 1)}
	local o = {math.random(0.1, 1), math.random(0.1, 1), math.random(0.1, 1), math.random(0.1, 1), math.random(0.1, 1)}
	local h = {math.random(0, 1), math.random(0, 1), math.random(0, 1)}
	local numWeights = 21
	local w = {}
	for i = 1, numWeights do
		w[i] = math.random(0, 10) / 10  -- random weight between 0 and 1
	end


	-- Calculating the hidden nodes --
	h[1] = i[1] * w[1] + i[2] * w[2] + h[1]
	h[2] = i[1] * w[3] + i[2] * w[4] + h[2]
	h[3] = i[1] * w[5] + i[2] * w[6] + h[3]

	-- Calculating the new hidden nodes that have been activated using tanh
	h[1] = math.tanh(h[1])
	h[2] = math.tanh(h[2])
	h[3] = math.tanh(h[3])

	-- Calculate the outputs --
	o[1] = o[1] + h[1] * w[7] +  h[2] * w[8]   + h[3] * w[9]
	o[2] = o[2] + h[1] * w[10] + h[2] * w[11] + h[3] * w[12]
	o[3] = o[3] + h[1] * w[13] + h[2] * w[14] + h[3] * w[15]
	o[4] = o[4] + h[1] * w[16] + h[2] * w[17] + h[3] * w[18]
	o[5] = o[5] + h[1] * w[19] + h[2] * w[20] + h[3] * w[21]

	-- Calculate the new outputs nodes that have been activated using tanh
	o[1] = math.tanh(o[1])
	o[2] = math.tanh(o[2])
	o[3] = math.tanh(o[3])
	o[4] = math.tanh(o[4])
	o[5] = math.tanh(o[5])

	-- Determine the highest output and act accordingly
	local maxOutput = math.max(o[1], o[2], o[3], o[4], o[5])
	if maxOutput == o[1] then
		part.BrickColor = BrickColor.new("Really red")
		part.Orientation = part.Orientation + Vector3.new(0, -45, 0)
		print("o[1] = " .. o[1] .. " o[2] = " .. o[2] .. " o[3] = " .. o[3] .. " o[4] = " .. o[4] .. " o[5] = " .. o[5])
		print("o[1] is the highest")
	elseif maxOutput == o[2] then
		part.BrickColor = BrickColor.new("Lime green")
		part.Position = part.Position + Vector3.new(1, 0, 0)
		print("o[1] = " .. o[1] .. " o[2] = " .. o[2] .. " o[3] = " .. o[3] .. " o[4] = " .. o[4] .. " o[5] = " .. o[5])
		print("o[2] is the highest")
	elseif maxOutput == o[3] then
		part.BrickColor = BrickColor.new("Bright blue")
		part.Position = part.Position + Vector3.new(0, 1, 0)
		print("o[1] = " .. o[1] .. " o[2] = " .. o[2] .. " o[3] = " .. o[3] .. " o[4] = " .. o[4] .. " o[5] = " .. o[5])
		print("o[3] is the highest")
	elseif maxOutput == o[4] then
		part.BrickColor = BrickColor.new("Bright yellow")
		part.Position = part.Position + Vector3.new(0, 0, 1)
		print("o[1] = " .. o[1] .. " o[2] = " .. o[2] .. " o[3] = " .. o[3] .. " o[4] = " .. o[4] .. " o[5] = " .. o[5])
		print("o[4] is the highest")
	else
		part.BrickColor = BrickColor.new("Bright orange")
		part.Position = part.Position + Vector3.new(-1, 0, 0)
		print("o[1] = " .. o[1] .. " o[2] = " .. o[2] .. " o[3] = " .. o[3] .. " o[4] = " .. o[4] .. " o[5] = " .. o[5])
		print("o[5] is the highest")
	end
end

neural network traveled 830 studs for nothing-