šŸ“™ Understanding Neuronal Networks presale is now open - 20% off discount!

What are Epochs in TensorflowJs

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 from Scratch - Presale

I'm writing a book about the timeless foundational concepts of neural networks for JavaScript developers. Go from if-else to weights and biases by building tiny AI models from scratch!

šŸ“– Neural Networks from Scratch - Presale

I'm writing a book about the timeless foundational concepts of neural networks for JavaScript developers. Go from if-else to weights and biases by building tiny AI models from scratch!


Leave a Reply

Your email address will not be published. Required fields are marked *