π±Introduction
π©βπ» 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.
β¨ What is Keras?
Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano.
π Important Terms
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
π©βπ¬ The Simplest Neural Network
It contains one layer with one neuron.
π©βπ» Code Example
# initialize the model
model = Sequential()
# add a layer with one unit and set the dimension of input
model.add(Dense(units=1, input_shape=[1]))
# set functional properties and compile the model
model.compile(optimizer='sgd', loss='mean_squared_error'
After building out neural network we can feed it with our sample data π
π©βπ» Code Example
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 π
π©βπ» Code Example
model.fit(xs, ys, epochs=500)
Every thing is done π ! Now we can test our neural network with new data π
π©βπ» Code Example
print(model.predict([10.0]))
π©βπ» My Code
π Traditional Programming vs Machine Learning
π§ References
Last updated
Was this helpful?