Neural Network Library (Obsolete)

If you mean repeating the entire training and testing process indefinitely, you can literally just put the entire script in 1 while loop. Nothing in the example is saved outside the script so it will be reset when the code runs again.

1 Like

But would I put the variable where I require the module outside the while true do loop? Or inside the while true do loop? And what about the place where I make the network as well (Basically the network variable)?

Sorry for asking all of these questions

2 Likes

Everything in the script should be inside the while loop other than the require statement; place it above the while loop. The network value is reset every loop so you don’t have to worry about it.

2 Likes

Is there any reason why you used “ReLU” rather than using something else like “Identity” in your example code?

3 Likes

It’s the most common activator in the NN community. That and “Identity” is a pretty bad activator and would give not very impressive results. “ReLU” is the safest bet other than the default “LeakyReLU”.

1 Like

So “LeakyReLU” would not be as safe to use then?

2 Likes

I didn’t use it simply because it is the default one and I wanted to demonstrate an example where you set the activator to something else.

2 Likes

Been planning on getting into Neural Networks, this will help greatly. Thanks for the contribution!

2 Likes

@Kironte Also, in the part where the network tries to guess the answer, how did you come up with that equation?

2 Likes

I have since realized that I can start for loops with negative iterators so lemme go ahead and fix that…

2 Likes

Hi,
First of all, great work!!

However, I would like to point out that in order to use such a library you need some kind of huge dataset of expected inputs and outputs. I am just stating that because most roblox developers do not understand how AI fundamentally works. In short, this module is not enough for you to create for example a npc AI.

Also, is there any reason to do this in lua? I think training of the network should be done offline, (on your pc or your personal private server) and afterwards you can query the network via http. This is quite bad if you need to do a lot of requests but I think trying to train something and use it in roblox lua would be even worse.

I still want to congratulate you for the module but we are still quite far from using AI in roblox.

4 Likes

If it can be automated, it can be done quite easily. Yes, it will take a while train a proper professional neural network, but I am sure that enthusiasts that are looking into neural networks are ready for these costs.

That is why I explicitly stated that in order to use this library you need surface level understanding of NNs. It should take a person about 20 minutes to get the understanding needed. Just because many people don’t know how to use NNs doesn’t mean that we shouldn’t start teaching them.

Highly disagree. Sure, you won’t be making a speech bot or fully automated enemy with just 1 NN, but you can easily find uses for NNs in such applications. You could, say, use a simple NN to teach an enemy how to react effectively against players’ movements. It will take lots of training but it is possible. There is actually a popular example of @ScriptOn using genetic networks to create some awesome self driving cars: Self-Driving Neural Network Cop Cars - #9 by ScriptOn
You can do that with this library. There would be lots of preparation but it is clearly possible.

Python has PyTorch and standard Lua has Torch as NN libraries; Roblox has none (that are comparable). There is no point in playing with NNs outside of Roblox for me because I want to make them from scratch, not just use someone else’s work and do something that anyone else can do with barely any knowledge. However, not everyone feels this way. That is why I open sourced this library; for those who want to learn NNs and those who want to use them without delving too deeply into the math behind them.

That is how NNs are done outside of Roblox. For Roblox, things are done differently. That, and running the training on an AFK Client basically does the same thing anyway. LuaJIT does work well but I could never get it to work with the genetic algorithm, no clue why.

Again, examples from people like ScriptOn prove otherwise. We have the power to make AI already, it just takes lots of effort and dedication to do so.

8 Likes

Out of curiosity, how should I decide how many hidden layers, and hidden neurons should there be in a neural network?

2 Likes

For the layer count; there is no exact science. Overall, you should stick to 1-2 layers, 3 at most. More than that and your network becomes ‘deep’, making it very difficult and time consuming to train.
For node count, generally, try to put more for complex programs and less for simple ones. 10 is really as high as you should ever go on Roblox while 3 is about as little as you should go. Too many nodes result in your network simply memorizing the things you trained it instead of learning, making it bad at extrapolating data.

1 Like

What would be considered a complex program? A zombie AI system? Or a basic system that teaches the neural network arithmetic?

2 Likes

It is very subjective, but usually, it can be judged by the number of inputs and outputs. The more of them, the more complex it is.

2 Likes

Hi I’m the friend. Glad you got interested in Neural Networks and made one that’s 5x as efficient as mine :slight_smile:

4 Likes

I was wondering when I would see Neural Networking done on ROBLOX! I have been following NNing for quite a while on youtube channels such as Jabrils, and I’m happy to see NN being incorporated here. Thank you for this library.

2 Likes

Is it possible to make a basic neural network that only has one input with this module?

2 Likes

Yes. It supports any number of inputs or outputs that Roblox can manage to run.

2 Likes