Day 2 (Or part 2): Neural networks and what you eat them with.

in #programming6 years ago (edited)

Hello again everyone!
This is my second post about the game with a neural network that I am making.
If you haven't seen the first part, please check it out first.
https://steemit.com/neural-networks/@reborninferno/day-1-unity-neural-networks-and-c

This time there won't be much code, but rather more of explanation what neural networks are.
will try to explain as simple as I can, hopefully, you won't be lost. If you have any questions after this, please comment below and I will try to answer the best I can.

I am by no means an expert in this field, I am starting out myself but I would like to share my knowledge nonetheless.

what are neural networks?

Neural networks are essentially an emulation of our brain, but of course not as complicated, yet...
of course, we don't understand our own brains yet but we do understand the neurons to some extent.

You see, in neural networks, we have 3 parts:
1.Inputs,
2.Hidden layer (all the neurons in between),
3.Outputs,

Inputs can be anything really, something as simple as a number input
to something complex as hundreds or thousands of values from pixels of the camera input

Hidden layers are exactly what they sound like.
We do not know the values in them we only control the weights and biases of the neurons in those layers (more about that later).

And finally, we have the outputs, which of course depends on what your network is.
If it's some kind of yes or no problem, then there would be 1 output and the value would be 1(yes) or 0(no).

Now, How do they look like, you ask?

Pretty much as you would think, a bunch of "neurons" connected to each other as such:

What you see here is a neural network with:
a. 2 Inputs,
b. 1 Hidden layer with 3 neurons
c. 1 Output.

this is a pretty simple example, however, there are way more types of networks, some have way more layers, some have memory cells e.t.c.
This results in all kinds of different networks used for various purposes.

Now that we've got the basics, let's see how they work.

But before we go any further we need to understand that each connection (the line between neurons) has a weight attached to it. Each neuron also has a weight attached to it, that we call a bias.

We will see how they are used in a second.

First, the inputs are transferred from the input cells into the connected neurons,
()

When the inputs reach the neurons, all of the inputs are multiplied by the weight of the connection (input * weight, this is done for each connection and it is then summed up),

Then we add the sum and the neuron's bias weight,(Sum + bias)

Another way of showing this is:

(Don't worry if you don't understand this.)

Where the weights are "w" and input values are "x", "i" represents each connection, and"b" is a bias that we talked about.
Pretty simple so far.

Then that value passes through what's known as "Activation Function",

What are the activation functions?

Pretty much it's a fancy formula that takes big values and makes them 1 and small values into 0.
This not only helps to make the network more stable but it also adds curves to our problem that before that was a linear problem, this adds more accuracy and potential correct answers percentage.

Examples of an Activation Function

Sigmoid: (returns a value from 0 to 1)

SoftSign: (returns a value from -1 to 1)
I am showing these two because these are the ones we are going to use, there are others and of course, it does matter which one you choose, but I just these because they came first to my mind.

Now that I showed you what activation functions I can now add this to our general equation:


You can see how this can become quite complicated with big networks of neurons.

Recap

Let's repeat what happens again,

  1. The inputs are received and sent to each connected neuron,
  2. Each neuron calculates the sum of each connection's value by input * weight,
  3. The bias is added to the sum and then it is passed into an activation function which "compresses" the value into something between 0 and 1 (Depending on the function you use).

What's next?

This process will go on and through each neuron until it reaches output.
but then the loop continues until you tell it to stop.
As Such:
()

But that's not all!

If we make the network right now and randomly generate all the weights and biases.
It will just give us equivalently random answers(unless we get really lucky).

So what we need to do is we need to Train the neural network.

Training pretty much means that we need to adjust those weights and biases in such a way that would each time we adjust them, they would give us more and more correct answers.
There are a lot of different techniques that are used to do this.

These are the 3 general groups of those methods:

("Although there are more of which I don't know :(")

1. Supervised Learning

When we Supervise the Ai, each time it makes a mistake, adjust the weights according to the error value this method is used when we do back propagation which is pretty much running the network the opposite way and adjusting the weights. This is useful when we have a lot of organized data which has the correct answers already assigned to it, using those inputs and answers we do what I said above.

2. Unsupervised Learning

This is where the Ai learns itself without any interference of the person,
it only has inputs and thus has to figure out on its own,

I do not know much about unsupervised learning as I've never learned much about it.

3. Reinforcement Learning

Well, It sounds exactly what it means, we try to provoke more of the desired behaviors and prohibit the undesired behaviors,
One of the ways to do this is Genetic Algorithm.
We assign fitness or reward to certain actions that result in the needed outcome, and negative values for the opposite.

The generations with the highest fitness values are chosen to be mixed to produce new generations.
We also add a few mutations to bring out new possibilities for the network.

This is what we're going to use for making our network in the next blog. I will make it step by step to try to make everyone understand what is going on.

This is the end of the post!

I hope you liked this post and if you did please leave a like and comment on anything you have a question about, and I will try to answer. Any suggestions are also welcomed!

If you didn't see my first post please check it out to understand the concept of these blog series.
https://steemit.com/neural-networks/@reborninferno/day-1-unity-neural-networks-and-c

Sort:  

Congratulations @reborninferno! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of upvotes

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:
SteemitBoard and the Veterans on Steemit - The First Community Badge.

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @reborninferno! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.20
TRX 0.25
JST 0.039
BTC 97402.80
ETH 3477.48
USDT 1.00
SBD 3.19