Rationale: Indicate type of model being loaded more explicitly in code.
// Before:
await tf.loadModel('http://server/model.json');A Pen by Shanqing Cai on CodePen.
| import keras | |
| import tensorflowjs as tfjs | |
| model = keras.applications.mobilenet.MobileNet(alpha=0.25) | |
| tfjs.converters.save_keras_model(model, '/tmp/mobilnet_0.25') |
| const tf = require('@tensorflow/tfjs'); | |
| require('@tensorflow/tfjs-node-gpu'); | |
| (async function() { | |
| const inputShape = [43, 232, 1]; | |
| const numClasses = 10; | |
| const model = tf.sequential(); | |
| model.add(tf.layers.conv2d({ | |
| filters: 8, kernelSize: [2, 8], |
| import time | |
| import tensorflow as tf | |
| tf.enable_eager_execution() | |
| # with tf.device('gpu:0'): | |
| def model(xs): | |
| ys = tf.keras.layers.Conv2D(8, [2, 8], activation='relu')(xs) | |
| ys = tf.keras.layers.MaxPool2D([2, 2], strides=[2, 2])(ys) |
| // To see the callback live, uncomment the following lines for and try the | |
| // code out with ts-node. | |
| // (async function() { | |
| // const model = tfl.sequential({layers: [ | |
| // tfl.layers.dense({units: 100, inputShape: [20], activation: 'relu'}), | |
| // tfl.layers.dense({units: 1}) | |
| // ]}); | |
| // model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); | |
| // const xs = tfc.ones([500, 20]); |