What are Epochs in TensorflowJs

šŸ“– 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!

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!


Leave a Reply

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

Home Screencasts Best of Newsletter Search X

Neural Networks for JavaScript developers
Presale - 15$ free coupon

Hi friend! Before you go, just wanted to let you know that in March 2023 I will be launching the TensorFlow.Js by Example course.

This course will include basic concepts of AI and Neural Networks done with TensorFlowJs such as:

  • Working with datasets
  • Visualizing training
  • Deep Neural Networks in JavaScript
  • Reinforcement Learning
  • Convolutional neural networks
  • and much more ...

Also, there will be a lot of examples as:

  • Object detection
  • Natural language processing
  • Face and voice recognition
  • Gaming AI

Join now the waiting list and get a 15$ coupon off the launching price!

X