TensorFlowJS Exception - Cannot start training because another fit() call is ongoing

你说的曾经没有我的故事 提交于 2019-12-06 01:30:50

When multiple fit are called on the same model, they have to be done sequentially. It means that the second call has to start only when the first one has completed. Using async and await will prevent your second call to happen unless the first has completed.

loss = await model.fit(resize_image[j], tesnor_dim[j], {epochs: 100})
// continue rest of processing

you may use this code,

await model.fit(resize_image[j], tesnor_dim[j], {epochs: 100}).then((loss) => {
     console.log('resize_image[j]',resize_image[j]);
     console.log('tesnor_dim[j]',tesnor_dim[j]);
     console.log('loss',loss);
     const t = model.predict(resize_image[j]);
     console.log('Prediction:::'+t);
     pred = t.argMax(1).dataSync(); // get the class of highest probability
            const labelsPred = Array.from(pred).map(e => setLabel[e])
            console.log('labelsPred:::'+labelsPred);
            //const saveResults = model.save('downloads://my-model-1');
            //console.log(saveResults);
        }).catch((e) => {
            console.log(e.message);
        })
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!