šŸ“• Build AI Agents using LangGraph.js is now out!

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.

šŸ“– Build a full trivia game app with LangChain

Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js

šŸ“– Build a full trivia game app with LangChain

Learn by doing with this FREE ebook! This 35-page guide walks you through every step of building your first fully functional AI-powered app using JavaScript and LangChain.js


Leave a Reply

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