Steps to set up a ML model
up:: Machine Learning
1. Define the neutral network
The inputShape is only one value. This model is initialised as a Dense Layer.
2. Compile the network
Needs two functions: loss and optimizer.
The model repeats this for a number of epochs.
Example using mean_squared_error
for the loss and stochastic gradient descent (sgd
) for the optimizer.
Info
The maths behind those methods doesn’t matter (yet). Over time you’ll learn which methods to use when.
3. Provide the Data
Here is some sample data:
X: | -1 | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|---|
Y: | -2 | 1 | 4 | 7 | 10 | 13 |
For our human eyes, it might be easy to discern that the formula is .
This is how you store the arrays in a numpy
array.
4. Train the model
Epochs are the number of loops the model will perform to train.
5. Make predictions
You’d expect the answer is 31
. Instead it is something like 31.003468
.
This is because there is very high probability the relationship between and is . But with six data points, it is not a certainty.
Working with neural networks, you will almost always deal with probabilities, not certainties.