eea

pct

eea
Dec 20th, 2021 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.87 KB | None | 0 0
  1. local modu = {}
  2.  
  3. owner.Chatted:Connect(function(z)
  4.     if z:sub(1, 7) == "$train " then
  5.        local ts = z:sub(7)
  6.        for l = 1,ts,1 do
  7.           modu:Train(math.random(0, 100), 1)
  8.           modu:Train(math.random(-100, -1), -1)
  9.           wait()
  10.        end
  11.        print("Weight: "..tostring(modu.weight))
  12.     end
  13. end)
  14.  
  15. modu.weight = math.random(-2, 2)
  16. modu.lr = .001
  17. print(modu.weight)
  18. function modu:Guess(input)
  19.     return math.sign(input * modu.weight)
  20. end
  21.  
  22. function modu:Train(input, target)
  23.     local erro = target - modu:Guess(input)
  24.     modu.weight += (input * erro * modu.lr)
  25. end
  26.  
  27.  
  28.  
  29. local pctp = Instance.new("Part", script)
  30. pctp.Position = (owner.Character.HumanoidRootPart.CFrame.LookVector * 8) + owner.Character.Head.Position + Vector3.new(0,2,0)
  31. pctp.Orientation = Vector3.new(owner.Character.HumanoidRootPart.Orientation.X, owner.Character.HumanoidRootPart.Orientation.Y - 180, owner.Character.HumanoidRootPart.Orientation.Z)
  32. pctp.Size = Vector3.new(10, 10, .5)
  33. pctp.Transparency = 1
  34. pctp.Anchored = true
  35.  
  36.  
  37.         local sg = Instance.new("SurfaceGui", pctp)
  38.         local ttb = Instance.new("TextLabel", sg)
  39.         local ib = Instance.new("TextBox", sg)
  40.         local wb = Instance.new("TextBox", sg)
  41.         local ob = Instance.new("TextLabel", sg)
  42.         local infobox = Instance.new("TextLabel", sg)
  43.         sg.Adornee = pctp
  44.         ttb.Size = UDim2.fromScale(1, .25)
  45.         ttb.BackgroundColor3 = Color3.new(0,0,0)
  46.         ttb.TextColor3 = Color3.new(1,1,1)
  47.         ttb.BorderColor3 = Color3.new(1,1,1)
  48.         ttb.TextScaled = true
  49.         ttb.Text = "Task: Find out whether a number is positive or negative."
  50.        
  51.         ib.Size = UDim2.fromScale(.25, .25)
  52.         ib.Position = UDim2.fromOffset(0, 250)
  53.         ib.BackgroundColor3 = Color3.new(0,0,0)
  54.         ib.BorderColor3 = Color3.new(1,1,1)
  55.         ib.TextScaled = true
  56.         ib.TextColor3 = Color3.new(1,1,1)
  57.         ib.Text = "Input: "
  58.         ib.TextEditable = false
  59.  
  60.         wb.Size = UDim2.fromScale(.25, .25)
  61.         wb.Position = UDim2.fromOffset(300, 250)
  62.         wb.BackgroundColor3 = Color3.new(0,0,0)
  63.         wb.BorderColor3 = Color3.new(1,1,1)
  64.         wb.TextScaled = true
  65.         wb.TextColor3 = Color3.new(1,1,1)
  66.         wb.Text = "Weight: "
  67.         wb.TextEditable = false
  68.        
  69.         ob.Size = UDim2.fromScale(.25, .25)
  70.         ob.Position = UDim2.fromOffset(600, 250)
  71.         ob.BackgroundColor3 = Color3.new(0,0,0)
  72.         ob.BorderColor3 = Color3.new(1,1,1)
  73.         ob.TextScaled = true
  74.         ob.TextColor3 = Color3.new(1,1,1)
  75.         ob.Text = "Output: "
  76.        
  77.         infobox.Size = UDim2.fromScale(1, .25)
  78.         infobox.Position = UDim2.fromOffset(0, 450)
  79.         infobox.BackgroundColor3 = Color3.new(0,0,0)
  80.         infobox.BorderColor3 = Color3.new(1,1,1)
  81.         infobox.TextColor3 = Color3.new(1,1,1)
  82.         infobox.TextScaled = true
  83.         infobox.Text = "1 = Positive, -1 = Negative."
  84.  
  85.  
  86. while true do
  87.     local rn = math.random(-100, 100)
  88.     ib.Text = "Input: "..tostring(rn)
  89.     local guess = modu:Guess(rn)
  90.     ob.Text = "Output: "..guess
  91.     wb.Text = "Weight: "..modu.weight
  92.     wait(3)
  93. end
Add Comment
Please, Sign In to add comment