• Torch/Machine Learning for gmod?
    5 replies, posted
I'm really interested in machine learning so I wondered if it's possible to implement torch (and maybe torch's lua threading) in gmod as its luajit compatible. I think it would be a missed opportunity to not let the gmod community tinker with it as machine learning is a rapidly growing field for anything that has some data you want to connect. [url]http://torch.ch/[/url] > [url]https://github.com/torch/torch7[/url] "Threads for Lua and LuaJIT. Transparent exchange of data between threads is allowed thanks to torch serialization." > [url]https://github.com/torch/threads[/url] What it can: -It can find patterns in the spawn behaviour of players to detect minges more reliably. Add data of their playtime to make the network associate the behaviour with playtime. (it could detect that new players are more likely to randomly spawn shit to crash the server) -Analyse movement of players to improve your map. The data could show from what point players are more like to go to certain other places so you could improve the ways or remove/rework unused areas completely. -Neural Network based path finding (seen one that reads the map of a subway from a photo and calculates the shortest path between points) Or it could be used to suggest servers like 'you might also like to play on'. Google even uses such algorithms to efficiently cool their data centers, give you personalized search results (just like facebooks personalized infinite scrolling), learn what ads work better for you (also just like facebook), etc... Speech recognition, speech synthesis, it can even make up a better diagnostic tool than a doctor finding rare deseases more reliably... it's applications are really just limited by your imagination (and gmods "non-multicore-policy" - ofc you wont run a 1k-layer deep neural net in gmod but 5 could already make a good ai). Uses could reach from more intelligent bots to a learing gui or everything else that involves data. Or just machine learning prototyping using gmod. What is Deep Learining and how does it work: [video=youtube;He4t7Zekob0]https://www.youtube.com/watch?v=He4t7Zekob0[/video] [URL="http://playground.tensorflow.org/#activation=tanh&batchSize=10&dataset=circle&regDataset=reg-plane&learningRate=0.03&regularizationRate=0&noise=0&networkShape=4,2&seed=0.53324&showTestData=false&discretize=false&percTrainData=50&x=true&y=true&xTimesY=false&xSquared=false&ySquared=false&cosX=false&sinX=false&cosY=false&sinY=false&collectStats=false&problem=classification&initZero=false&hideText=false"]playground.tensorflow.org[/URL] Cool example use: [video=youtube;rAbhypxs1qQ]https://www.youtube.com/watch?v=rAbhypxs1qQ[/video] [url]https://facepunch.com/showthread.php?t=1562320&p=52196265&viewfull=1#post52196265[/url] : [video=youtube;ftMq5ps503w]https://www.youtube.com/watch?v=ftMq5ps503w[/video] Training such a network is just as easy as giving input data and expected results for a problem so it learns to interpolate for non-training-data later on: [video=youtube;9KM9Td6RVgQ]https://www.youtube.com/watch?v=9KM9Td6RVgQ[/video]
"How to Predict Stock Prices Easily" i think u got clickbaited bro
[QUOTE=bloodmasked;52200764]"How to Predict Stock Prices Easily" i think u got clickbaited bro[/QUOTE] In fact I've watched those videos and it's less about predicting the stock prices but about how to predict sequential data. This way you could also predict handwriting for example or aimbot detection. [QUOTE=Rocket;52200803]A good portion of the Garry's Mod coding community hasn't graduated middle school yet. I don't know if machine learning would take off in that crowd.[/QUOTE] When I started coding (also in gmod) I didn't either. It's like saying why implement lua in the first place? The point is machine learning algorithms are not difficult to learn you just have to do so like you had when learning lua. And as soon as the first gmod based torch tutorials emerge everyone can get it. It's just as easy as setting up the network: [code]require "nn" mlp = nn.Sequential(); -- make a multi-layer perceptron (the default neural net) inputs = 2; outputs = 1; HUs = 20; -- parameters mlp:add(nn.Linear(inputs, HUs)) --add linear layer to the network with 2 inputs 20 outputs mlp:add(nn.Tanh()) --add a tanh layer with 20 inputs on a hidden node mlp:add(nn.Linear(HUs, outputs))--add linear layer to the network with 20 inputs and 1 output[/code] Network will look something like this where each layer is basically just a list of numbers and we only have 2 inputs, 1 output and 20 nodes on a hidden layer. [IMG]http://cs231n.github.io/assets/nn1/neural_net2.jpeg[/IMG] This untrained neural net has 20 inputs and 1 output. So the input to this neural net could be a simple table containing 20 values and for training also input 1 expected output. This network could drive a car forward/backwards based on 20 inputs and those 20 inputs could use manual (W-S) input as one input and 19 other iputs like sensor or orientation data. [code]criterion = nn.MSECriterion()[/code] --for evaluating the error in training This criterion uses the error^2 to learn from it. The error is how much the output differs from the expected output when having certein inputs. Training: [code] for i = 1,2500 do --2500 times to train the network -- random sample local input= torch.randn(2); -- normally distributed example in 2d local output= torch.Tensor(1); if input[1]*input[2] > 0 then -- calculate label for XOR function (the network will mimic the XOR function after training enough) output[1] = -1 else output[1] = 1 end -- feed it to the neural network and the criterion criterion:forward(mlp:forward(input), output) -- train over this example in 3 steps: -- (1) zero the accumulation of the gradients mlp:zeroGradParameters() -- (2) accumulate gradients mlp:backward(input, criterion:backward(mlp.output, output)) -- (3) update parameters with a 0.01 learning rate (low learning rate = more precise = slower) mlp:updateParameters(0.01) end [/code] If you use these ~20lines of code you're ready to work with the torch library. [B]My point is you really just need to know: -how many inputs do you need -how many outputs do you need -what you expect the outputs to be for certain inputs [/B] After you got that train the network on the data and afterwards your network can be used by inputting real data and using the outputs the network provides. Example code taken form: [url]https://github.com/torch/nn/blob/master/doc/training.md#nn.traningneuralnet.dok[/url]
I've implemented the GA HyperNeat as a module for GMod, I might release it once I've fixed a few things and I would like to add coroutine support. EDIT: [thumb]http://share.epic-domain.com/hl2_2017-05-05_19-30-24.jpg[/thumb] Input is simple line traces and output is rgb. Its a little fun expirement.
Have you seen this? [url]https://github.com/wixico/luann[/url]
Sorry, you need to Log In to post a reply to this thread.