(exportPath)
| 89 | |
| 90 | // Convolutional neural network (CNN). |
| 91 | async function exportCNNModel(exportPath) { |
| 92 | const model = tfl.sequential(); |
| 93 | |
| 94 | // Cover separable and non-separable convoluational layers. |
| 95 | const inputShape = [40, 40, 3]; |
| 96 | model.add(tfl.layers.conv2d({ |
| 97 | filters: 32, |
| 98 | kernelSize: [3, 3], |
| 99 | strides: [2, 2], |
| 100 | inputShape, |
| 101 | padding: 'valid', |
| 102 | })); |
| 103 | model.add(tfl.layers.batchNormalization({})); |
| 104 | model.add(tfl.layers.activation({activation: 'relu'})); |
| 105 | model.add(tfl.layers.dropout({rate: 0.5})); |
| 106 | model.add(tfl.layers.maxPooling2d({poolSize: 2})); |
| 107 | model.add(tfl.layers.separableConv2d({ |
| 108 | filters: 32, |
| 109 | kernelSize: [4, 4], |
| 110 | strides: [3, 3], |
| 111 | })); |
| 112 | model.add(tfl.layers.batchNormalization({})); |
| 113 | model.add(tfl.layers.activation({activation: 'relu'})); |
| 114 | model.add(tfl.layers.dropout({rate: 0.5})); |
| 115 | model.add(tfl.layers.avgPooling2d({poolSize: [2, 2]})); |
| 116 | model.add(tfl.layers.flatten({})); |
| 117 | model.add(tfl.layers.dense({units: 100, activation: 'softmax'})); |
| 118 | |
| 119 | await saveModelAndRandomInputs(model, exportPath); |
| 120 | } |
| 121 | |
| 122 | async function exportDepthwiseCNNModel(exportPath) { |
| 123 | const model = tfl.sequential(); |
no test coverage detected
searching dependent graphs…