šŸŽ Checkout my Learn React by Making a Game course and get 1 month Free on Skillshare!

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.

šŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.

šŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.


Leave a Reply

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