Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modu = {}
- owner.Chatted:Connect(function(z)
- if z:sub(1, 7) == "$train " then
- local ts = z:sub(7)
- for l = 1,ts,1 do
- modu:Train(math.random(0, 100), 1)
- modu:Train(math.random(-100, -1), -1)
- wait()
- end
- print("Weight: "..tostring(modu.weight))
- end
- end)
- modu.weight = math.random(-2, 2)
- modu.lr = .001
- print(modu.weight)
- function modu:Guess(input)
- return math.sign(input * modu.weight)
- end
- function modu:Train(input, target)
- local erro = target - modu:Guess(input)
- modu.weight += (input * erro * modu.lr)
- end
- local pctp = Instance.new("Part", script)
- pctp.Position = (owner.Character.HumanoidRootPart.CFrame.LookVector * 8) + owner.Character.Head.Position + Vector3.new(0,2,0)
- pctp.Orientation = Vector3.new(owner.Character.HumanoidRootPart.Orientation.X, owner.Character.HumanoidRootPart.Orientation.Y - 180, owner.Character.HumanoidRootPart.Orientation.Z)
- pctp.Size = Vector3.new(10, 10, .5)
- pctp.Transparency = 1
- pctp.Anchored = true
- local sg = Instance.new("SurfaceGui", pctp)
- local ttb = Instance.new("TextLabel", sg)
- local ib = Instance.new("TextBox", sg)
- local wb = Instance.new("TextBox", sg)
- local ob = Instance.new("TextLabel", sg)
- local infobox = Instance.new("TextLabel", sg)
- sg.Adornee = pctp
- ttb.Size = UDim2.fromScale(1, .25)
- ttb.BackgroundColor3 = Color3.new(0,0,0)
- ttb.TextColor3 = Color3.new(1,1,1)
- ttb.BorderColor3 = Color3.new(1,1,1)
- ttb.TextScaled = true
- ttb.Text = "Task: Find out whether a number is positive or negative."
- ib.Size = UDim2.fromScale(.25, .25)
- ib.Position = UDim2.fromOffset(0, 250)
- ib.BackgroundColor3 = Color3.new(0,0,0)
- ib.BorderColor3 = Color3.new(1,1,1)
- ib.TextScaled = true
- ib.TextColor3 = Color3.new(1,1,1)
- ib.Text = "Input: "
- ib.TextEditable = false
- wb.Size = UDim2.fromScale(.25, .25)
- wb.Position = UDim2.fromOffset(300, 250)
- wb.BackgroundColor3 = Color3.new(0,0,0)
- wb.BorderColor3 = Color3.new(1,1,1)
- wb.TextScaled = true
- wb.TextColor3 = Color3.new(1,1,1)
- wb.Text = "Weight: "
- wb.TextEditable = false
- ob.Size = UDim2.fromScale(.25, .25)
- ob.Position = UDim2.fromOffset(600, 250)
- ob.BackgroundColor3 = Color3.new(0,0,0)
- ob.BorderColor3 = Color3.new(1,1,1)
- ob.TextScaled = true
- ob.TextColor3 = Color3.new(1,1,1)
- ob.Text = "Output: "
- infobox.Size = UDim2.fromScale(1, .25)
- infobox.Position = UDim2.fromOffset(0, 450)
- infobox.BackgroundColor3 = Color3.new(0,0,0)
- infobox.BorderColor3 = Color3.new(1,1,1)
- infobox.TextColor3 = Color3.new(1,1,1)
- infobox.TextScaled = true
- infobox.Text = "1 = Positive, -1 = Negative."
- while true do
- local rn = math.random(-100, 100)
- ib.Text = "Input: "..tostring(rn)
- local guess = modu:Guess(rn)
- ob.Text = "Output: "..guess
- wb.Text = "Weight: "..modu.weight
- wait(3)
- end
Add Comment
Please, Sign In to add comment