MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / getModel

Function getModel

intent-classifier/training/intent_model.js:32–50  ·  view source on GitHub ↗

* Returns a new ready-to-train tf.Model that classifies 512 dimensional vectors * into one of labels.length categories. * * The intended use is for the inputs to be embeddings from the universal * sentence encoder and labels to be the categories we want to classify those * sentence into. * *

(labels)

Source from the content-addressed store, hash-verified

30 * @return {tf.Model} the model instance
31 */
32function getModel(labels) {
33 const NUM_CLASSES = labels.length;
34 const EMBEDDING_DIMS = 512;
35
36 const model = tf.sequential();
37 model.add(tf.layers.dense({
38 inputShape: [EMBEDDING_DIMS],
39 units: NUM_CLASSES,
40 activation: 'softmax',
41 }));
42
43 model.compile({
44 optimizer: 'adam',
45 loss: 'categoricalCrossentropy',
46 metrics: ['accuracy'],
47 });
48
49 return model;
50}
51
52module.exports = {
53 getModel,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected