()
| 24 | * https://github.com/cmasch/zalando-fashion-mnist/blob/master/Simple_Convolutional_Neural_Network_Fashion-MNIST.ipynb |
| 25 | */ |
| 26 | export function createModel() { |
| 27 | const model = tf.sequential(); |
| 28 | model.add(tf.layers.batchNormalization({ |
| 29 | inputShape: [28, 28, 1] |
| 30 | })); |
| 31 | model.add(tf.layers.conv2d({ |
| 32 | filters: 64, |
| 33 | kernelSize: 4, |
| 34 | padding: 'same', |
| 35 | activation: 'relu', |
| 36 | })); |
| 37 | model.add(tf.layers.maxPooling2d({poolSize: 2})); |
| 38 | model.add(tf.layers.dropout({rate: 0.1})); |
| 39 | model.add(tf.layers.conv2d({ |
| 40 | filters: 64, |
| 41 | kernelSize: 4, |
| 42 | activation: 'relu', |
| 43 | })); |
| 44 | model.add(tf.layers.maxPooling2d({poolSize: 2})); |
| 45 | model.add(tf.layers.dropout({rate: 0.3})); |
| 46 | model.add(tf.layers.flatten()); |
| 47 | model.add(tf.layers.dense({units: 256, activation: 'relu'})); |
| 48 | model.add(tf.layers.dropout({rate: 0.5})); |
| 49 | model.add(tf.layers.dense({units: 64, activation: 'relu'})); |
| 50 | model.add(tf.layers.batchNormalization()); |
| 51 | model.add(tf.layers.dense({units: 10, activation: 'softmax'})); |
| 52 | |
| 53 | compileModel(model); |
| 54 | return model; |
| 55 | } |
| 56 | |
| 57 | export function compileModel(model) { |
| 58 | const optimizer = 'adam'; |
nothing calls this directly
no test coverage detected