Neural Network Library (Obsolete)

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

Wow. I’ll be honest with you, that’s pretty damn impressive. Huge +1 for this.

I may make extensive use of this in my game for certain NPC behaviors. If I do, you’re definitely getting a huge shoutout for it, should the module cater to my precise needs (which, from what reading I’ve done, it most certainly should).

Outstanding work. I’ll be messing around with this for quite some time, I believe.

6 Likes

What makes other ones so bad? Like why would “Identity”, “Binary”, etc… be so bad? I tested alot of them, and alot of them were constantly above 60% correct.

2 Likes

This is because they are either very simple and are not optimized enough to work well, or they are meant for very specific situations, which is why I allow the option to be there anyway.
Usually, ReLU and its subtypes are the ones you need. Sometimes,when you delve much deeper into neural networking, you may need a specific function for some niche AI, so I add that extra bit of customization.

2 Likes

I tried making a simple system which would detect if a number is negative or not with this module-script, and alot of times when I would print the amount of times the neural network would be correct, it would be a value similar to the one before, is this normal?

2 Likes

In small/simple networks, absolutely. This is because with simple problems, it doesn’t take long for any random network to arrive at the same solution in a similar amount of time. Most networks behave like this. The rest are outliers, networks that either have a fatal flaw that causes them to hit a local minimum (as good as it can do) too early, or networks that have good parameters and hit that minimum later on, giving better results.
This is why with the example script I gave, most of the time, you’ll be getting an accuracy of 98%. Sometimes you’ll get 98.7%, sometimes it dies early and you get 70-90%.

1 Like

Is there anything that I can do about this? I always want my neural network to be above a minimum of 50%, but I don’t want it to constantly have the same wins / “corrects” at one time.

2 Likes