* 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)
| 30 | * @return {tf.Model} the model instance |
| 31 | */ |
| 32 | function 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 | |
| 52 | module.exports = { |
| 53 | getModel, |
nothing calls this directly
no outgoing calls
no test coverage detected