This semester in college I took a computer vision course. In this course, I was required to write a program that can determine if the silhouette of an image is a dog, cat, bird, or dolphin. This program was required to use a Neural Network. Me being very well versed in Lua decided to implement my assignment in Lua/Löve. I extracted the Lua Neural Network and put it in its own GitHub repository. I am really interested in Neural Networks so I plan to expand on this a great deal, but currently, it is extremely simple. I based this code off of a gist I found online. Attached is a horrible example in use. Hopefully, I will make a better example in the future.
https://github.com/Bobbyjoness/LuaNeuralNet/tree/master
Lua Neural Network
-
- Party member
- Posts: 728
- Joined: Sat Apr 26, 2014 7:46 pm
Lua Neural Network
- Attachments
-
example.love
- (710.19 KiB) Downloaded 157 times
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.
Re: Lua Neural Network
What's the code doing? I see some line only.
-
- Party member
- Posts: 728
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Lua Neural Network
It is training the neural net to classify birds, dogs, cats, and dolphins. The line is the softmax value. Essentially its Accuracy/Epoch.
Edit: I meant its accuracy as y and x is epoch(training cycle) it is a graph.
Edit: I meant its accuracy as y and x is epoch(training cycle) it is a graph.
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.
Re: Lua Neural Network
Hi! I wrote this code using your Network but it doesn't work.
What am I missing?
That just prints 1.
What am I missing?
Code: Select all
local NeuralNetwork = require("lnn")
math.randomseed(os.time())
local nn = NeuralNetwork.create(2, 1, 2, 2, 0.3)
local training_data = {
{
inputs = {0, 1},
target = {1}
},
{
inputs = {1, 1},
target = {0}
},
{
inputs = {1, 0},
target = {1}
},
{
inputs = {0, 0},
target = {0}
}
}
for i = 1, 2000 do
local data = training_data[math.random(#training_data)]
nn:backwardPropagate(data.inputs, data.target)
end
print(nn:forwardPropagate({0, 1})[1])
print(nn:forwardPropagate({1, 1})[1])
print(nn:forwardPropagate({0, 0})[1])
print(nn:forwardPropagate({1, 0})[1])
- yintercept
- Citizen
- Posts: 64
- Joined: Mon Apr 02, 2018 3:31 pm
Re: Lua Neural Network
Cool as hell
A guy made something lsimilar back in april, you might enjoy talking with him and sharing notes bobby.
viewtopic.php?f=5&t=85089&p=226763&hilit=neural#p226763
A guy made something lsimilar back in april, you might enjoy talking with him and sharing notes bobby.
viewtopic.php?f=5&t=85089&p=226763&hilit=neural#p226763
Back in the saddle again.
-
- Party member
- Posts: 728
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Lua Neural Network
I pushed a fix to my repo. The softmax function didn't account for a singular output. Also, you have to up the training cycles to a much higher quantity if you want the neural net to output a 1. You can also play with the learning rate and etc.caralse wrote: ↑Fri May 17, 2019 9:52 amHi! I wrote this code using your Network but it doesn't work.
What am I missing?
That just prints 1.Code: Select all
local NeuralNetwork = require("lnn") math.randomseed(os.time()) local nn = NeuralNetwork.create(2, 1, 2, 2, 0.3) local training_data = { { inputs = {0, 1}, target = {1} }, { inputs = {1, 1}, target = {0} }, { inputs = {1, 0}, target = {1} }, { inputs = {0, 0}, target = {0} } } for i = 1, 2000 do local data = training_data[math.random(#training_data)] nn:backwardPropagate(data.inputs, data.target) end print(nn:forwardPropagate({0, 1})[1]) print(nn:forwardPropagate({1, 1})[1]) print(nn:forwardPropagate({0, 0})[1]) print(nn:forwardPropagate({1, 0})[1])
Do you frequently have great ideas but immediately lose them? Check out the MVP for my website called IdeaVault. It is designed to solve that problem. Desktop browsers only currently.
Who is online
Users browsing this forum: No registered users and 57 guests