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?