Keras Model - 2.0 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2022-01-20
Version
2.0 English

tf.keras allows model weights to be saved in two formats: HDF5 and TensorFlow. Only the TensorFlow format is currently supported by the tool. If the model weights have been saved in the HDF5 format, convert it to the TensorFlow format before proceeding.

import tensorflow as tf
tf.keras.backend.set_learning_phase(0)
model = tf.keras.applications.ResNet50(weights="imagenet",
    include_top=True,
    input_tensor=None,
    input_shape=None,
    pooling=None,
    classes=1000)
model.save_weights("model.ckpt", save_format='tf')

The converted checkpoint files look like this:

model.ckpt.data-00000-of-00001
model.ckpt.data-00001-of-00002
model.ckpt.index