Use with TensorFlow model

In this tutorial, we’ll convert model in TensorFlow [1] into WebDNN execution format.

  1. Construct TensorFlow computation graph
import tensorflow as tf

# y = x @ W + b
x = tf.placeholder(tf.float32, [None, 784])
W = tf.Variable(tf.zeros([784, 10]))
b = tf.Variable(tf.zeros([10]))
y = tf.nn.softmax(tf.matmul(x, W) + b)
  1. Convert to WebDNN graph
from webdnn.frontend.tensorflow import TensorFlowConverter
graph = TensorFlowConverter().convert([x], [y])
  1. Generate and save execution information.
from webdnn.backend import generate_descriptor

exec_info = generate_descriptor("webgpu", graph)  # also "webassembly", "webgl", "fallback" are available."./output")

To run converted model on web browser, please see “#3. Run on web browser” in keras tutorial