Use with TensorFlow model¶
In this tutorial, we’ll convert model in TensorFlow [1] into WebDNN execution format.
- 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)
- Convert to WebDNN graph
from webdnn.frontend.tensorflow import TensorFlowConverter
graph = TensorFlowConverter().convert([x], [y])
- Generate and save execution information.
from webdnn.backend import generate_descriptor
exec_info = generate_descriptor("webgpu", graph) # also "webassembly", "webgl", "fallback" are available.
exec_info.save("./output")
To run converted model on web browser, please see “#3. Run on web browser” in keras tutorial
References
[1] | https://www.tensorflow.org |