👩💻 Intro to Neural Networks Coding

Like every first app we should start with something super simple that gives us an idea about the whole methodology.

Keras is a high-level **neural networks API**, written in Python and capable of running on top of TensorFlow, CNTK, or Theano.

Term | Description |

Dense | A layer of neurons in a neural network |

Loss Function | A mathematical way of measuring how wrong your predictions are |

Optimizer | An algorithm to find parameter values which correspond to minimum value of loss function |

It contains one layer with one neuron.

# initialize the modelmodel = Sequential()# add a layer with one unit and set the dimension of inputmodel.add(Dense(units=1, input_shape=[1]))# set functional properties and compile the modelmodel.compile(optimizer='sgd', loss='mean_squared_error')

After building out neural network we can feed it with our sample data 😋

xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float)ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float)

Then we have to start training process 🚀

model.fit(xs, ys, epochs=500)

Every thing is done 😎 ! Now we can test our neural network with new data 🎉

print(model.predict([10.0]))