Learning in loop, init tenserflow js

Hi! How possible create init function for tf, i use loop and when call onTrainEnd i need reset all in tf. Should this be done? or does it do it itself?

Hi @gotostereo ,

I apologize for the late in my response. You can create an init function in TFJS that contains all the model’s initial operations.

function init() {
   1. Load or Define your model
   2. Define your optimizer
  3. Prepare your data (this is just a placeholder)
  4. Compile the model
}

Then, you can call this init function before you start training your model.

You also need to dispose of the tensors. You can either use the tf.dispose() function or use tf.tidy() and ensure that you don’t return any tensors during training. Once onTrainEnd is called, it will automatically dispose of all the tensors.

Let me know if that helps. Thank You!!!