November 2019
Intermediate to advanced
296 pages
7h 52m
English
To convert a Keras HDF5 model into the web format, you need to specify the keras input format option. Let's assume we want to convert the following model trained through the Keras API into the web format:
import tensorflow as tffrom tensorflow.keras import layersimport numpy as npmodel = tf.keras.Sequential()model.add(layers.Dense(32, activation='relu'))# Add another:model.add(layers.Dense(10, activation='softmax'))model.compile(optimizer=tf.train.AdamOptimizer(0.001), loss='categorical_crossentropy', metrics=['accuracy'])data = np.random.random((1000, 32))labels = np.random.random((1000, 10))model.fit(data, labels, epochs=10, batch_size=32)model.save('my_keras_model.h5')
You do not need to specify additional options ...
Read now
Unlock full access