Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created March 16, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/5bdd9fa0be36dcd20654f2f199c541d8 to your computer and use it in GitHub Desktop.
Save NMZivkovic/5bdd9fa0be36dcd20654f2f199c541d8 to your computer and use it in GitHub Desktop.
/**
* @desc trains model
* @return trained model
*/
async function trainModelFunction(model, inputs, outputs, epochs) {
model.compile({
optimizer: tf.train.adam(),
loss: 'categoricalCrossentropy',
metrics: ['accuracy'],
});
const batchSize = 64;
return await model.fit(inputs, outputs, {
batchSize,
epochs,
shuffle: true,
callbacks: tfvis.show.fitCallbacks(
{ name: 'Training Performance' },
['loss', 'accuracy'],
{ height: 200, callbacks: ['onEpochEnd'] }
)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment