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

Function createModel

quantization/model_mnist.js:20–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18import * as tf from '@tensorflow/tfjs';
19
20export function createModel() {
21 const model = tf.sequential();
22 model.add(tf.layers.conv2d({
23 inputShape: [28, 28, 1],
24 filters: 32,
25 kernelSize: 3,
26 activation: 'relu',
27 }));
28 model.add(tf.layers.conv2d({
29 filters: 32,
30 kernelSize: 3,
31 activation: 'relu',
32 }));
33 model.add(tf.layers.maxPooling2d({poolSize: [2, 2]}));
34 model.add(tf.layers.conv2d({
35 filters: 64,
36 kernelSize: 3,
37 activation: 'relu',
38 }));
39 model.add(tf.layers.conv2d({
40 filters: 64,
41 kernelSize: 3,
42 activation: 'relu',
43 }));
44 model.add(tf.layers.maxPooling2d({poolSize: [2, 2]}));
45 model.add(tf.layers.flatten());
46 model.add(tf.layers.dropout({rate: 0.25}));
47 model.add(tf.layers.dense({units: 512, activation: 'relu'}));
48 model.add(tf.layers.dropout({rate: 0.5}));
49 model.add(tf.layers.dense({units: 10, activation: 'softmax'}));
50
51 compileModel(model);
52 return model;
53}
54
55export function compileModel(model) {
56 const optimizer = 'rmsprop';

Callers

nothing calls this directly

Calls 1

compileModelFunction · 0.70

Tested by

no test coverage detected