Let's take the very simple training data from house price prediction TensorflowJs example:
// define the training data
const numberOfRooms = tf.tensor1d([2,4,3,8,5,6])
const prices = tf.tensor1d([190,374,245,732,420,560])
// train the model
return model.fit(numberOfRooms, prices, {epochs: some_value})
An epoch
is when the TensorflowJs network has seen every single training example once.
You can also see an epoch
as a full training loop.
We will need to carry out multiple epochs in order to improve the accuracy of our neural network. Something like this:
for (let epochIndex = 0; epochIndex < epochNo; epochIndex++) {
for(let index = 0; index < dataNo; index++) {
const data = datas[index]
const label = labels[index]
trainNetwork(data, labels)
}
}
Setting aside the CPU resource consumption, this means that the more epochs we do the better our neural network becomes?
Well, yes and no. The models improve with more epochs of training, to a point. After that, the accuracy starts to plateau.
We will need to see where it levels out. From that plateau, the only way to improve the accuracy will be just by doing things such as increasing the size of the training data set, improving the quality of the training data, choosing a more appropriate loss function, and so on.
š Neural networks for Javascript developers
The Neural Networks for JavaScript developers book is almost ready! Learn the basics of AI with TensorFlowJs examples. Join now the presale and get a 15$ coupon off the launching price!