Skip to content

Instantly share code, notes, and snippets.

@zaidalyafeai
Created April 3, 2018 22:56
Show Gist options
  • Save zaidalyafeai/60076e246d6f62d647c7468b88f49460 to your computer and use it in GitHub Desktop.
Save zaidalyafeai/60076e246d6f62d647c7468b88f49460 to your computer and use it in GitHub Desktop.
const model = tf.sequential();
//create the first layer
model.add(tf.layers.conv2d({
inputShape: [28, 28, 1],
kernelSize: 5,
filters: 8,
strides: 1,
activation: 'relu',
kernelInitializer: 'VarianceScaling'
}));
//create a max pooling layer
model.add(tf.layers.maxPooling2d({
poolSize: [2, 2],
strides: [2, 2]
}));
//create the second conv layer
model.add(tf.layers.conv2d({
kernelSize: 5,
filters: 16,
strides: 1,
activation: 'relu',
kernelInitializer: 'VarianceScaling'
}));
//create a max pooling layer
model.add(tf.layers.maxPooling2d({
poolSize: [2, 2],
strides: [2, 2]
}));
//flatten the layers to use it for the dense layers
model.add(tf.layers.flatten());
//dense layer with output 10 units
model.add(tf.layers.dense({
units: 10,
kernelInitializer: 'VarianceScaling',
activation: 'softmax'
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment