May 2020
Intermediate to advanced
404 pages
10h 52m
English
We will now write an async function. The reason for doing this is so that the JavaScript on the client side that invokes our function doesn't get stuck waiting for the result. A function that will take time to complete in our program is the train_data() function. This function performs the training of the model:
async function train_data(){ console.log("Training Started"); for(let i=0;i<50;i++){ let res = await model.fit(trainingData, outputData, {epochs: 50}); console.log(`Iteration ${i}: ${res.history.loss[0]}`); } console.log("Training Complete");}
The train_data() function can be run asynchronously. It also prints out the loss at every epoch of training to the console where we will run the server from. Let's now ...
Read now
Unlock full access