Error importing tf.keras Xception Model

Hi. I’m trying to load a model from TF 2.0 into dl4j. This is the structure:

base_model = tf.keras.applications.Xception(input_shape=[IMG_SIZE, IMG_SIZE, 3], include_top=False,weights='imagenet')
model = tf.keras.Sequential([
         base_model,
         Conv2D(256, 3, padding='same', activation='relu'),
         MaxPooling2D(),
         Conv2D(512, 3, padding='same', activation='relu'),
         MaxPooling2D(),
         Flatten(),
         Dense(4096, activation='relu', name='hidden_layer_0'),
         Dropout(0.3),
         Dense(2048, activation='relu', name='hidden_layer_1'),
         Dropout(0.3),
         Dense(1024, activation='relu', name='hidden_layer_2'),
         Dense(512, activation='relu', name='hidden_layer_3'),
         Dense(N_LABELS, name='output')
        ])

When importing I get an UnsupportedKerasConfigurationException: Unsupported keras layer type Model where Model is the name of the xception part in my model.h5 file. I think the problem is that the base_model encapsulates the xception network which isn’t understood by the keras importer. Any ideas on how to solve this?

At the moment we don’t support tf.keras based models. Unfortunately they’ve changed the model format and even the original Keras can’t import them anymore.

We are aware that there is a growing need for tf.keras import. This github issue tracks the progress:

So to clarify, I would have to train my model in the standalone Keras version (version 2.2.*) to be able to export it to DL4J? Or would an early version of tf.keras (prior to tf 2.0) also work?

I’m not quite familiar with earlier tf.keras versions. If they can be imported by standalone keras, then they should also be importable with dl4j (with the other caveats about importing keras model in general still applying).

I was able to freeze the model and generate a .pb file. Unfortunately while importing using sameDiff I get Could not find class for TF Ops: FusedBatchNormV3 (same issue as this)

Is inceptionV3 not supported?

Unfortunately, the FusedBatchNormV3 op is currently not supported.