Keras Model - 1.4.1 English

Vitis AI Optimizer User Guide (UG1333)

Document ID
UG1333
Release Date
2021-10-29
Version
1.4.1 English

tf.keras allows model weights to be saved in two formats: HDF5 and TensorFlow format. Currently only TensorFlow format is supported by the tool. If the model weights have been saved in HDF5, then you have to convert it to TensorFlow format.

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