Skip to content

Latest commit

 

History

History

lenet

WebNN API LeNet Example

This example showcases the LeNet-based handwritten digits classification by WebNN API.

This example leverages the network topology of the LeNet example of Caffe*, the weights of the LeNet example of OpenVINO* and the MNIST dataset of mnist.js.

The following diagram illustrates the topology of lenet.prototxt.

topology

The following table lists the corresponding WebNN ops and parameters for each layer.

Layer (name:type) WebNN op Parameters
conv1: Convolution nn.conv2d input shape [1, 1, 28, 28], filter shape [20, 1, 5, 5], layout "nchw"
nn.add bias shape [1, 20, 1, 1]
pool1: Pooling nn.maxPool2d window shape [2, 2], strides [2, 2]
conv2: Convolution nn.conv2d filter shape [50, 20, 5, 5], layout "nchw"
nn.add bias shape [1, 50, 1, 1]
pool2: Pooling nn.maxPool2d window shape [2, 2], strides [2, 2]
ip1: InnerProduct nn.matmul transposed weights shape [800, 500]
nn.add bias shape [1, 500]
relu1: ReLU nn.relu
ip2: InnerProduct nn.matmul transposed weights shape [500, 10]
nn.add bias shape [1, 10]
prob: Softmax nn.softmax output shape [1, 10]

Usage

Click the Device switch button to choose device preference for inference.

Click the Predict button to predict the digit shown in the canvas.

Click the Next button to pick up another digit from MNIST dataset.

Click the Clear button to clear the canvas and use mouse to draw a digit manually.

Screenshots

Predict the MNIST digit

screenshot

Predict the mannually drawing digit

screenshot