# Error importing tf.keras Xception Model

**URL:** <https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232>\
**Category:** DL4J\
**Created:** [March 5, 2020, 11:58am UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232 "2020-03-05T11:58:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lln](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lln](https://community.konduit.ai/u/lln)\
**Post date:** [March 5, 2020, 11:58am UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/1 "2020-03-05T11:58:25Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [March 5, 2020, 12:10pm UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/2 "2020-03-05T12:10:23Z")

</div>

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:

> <https://github.com/eclipse/deeplearning4j/issues/8348>
>
> TensorFlow 2 has 'build in' Keras model saving support:
> https://www.tensorflow.…org/tutorials/keras/save\_and\_load#hdf5\_format
> 
> It looks like there are some format differences between this and the standard Keras model saving.
> 
> tf.keras is not yet tested with DL4J Keras import, but we know that there are some issues as of 1.0.0-beta5. For example:
> https://github.com/eclipse/deeplearning4j/issues/8338
> https://github.com/eclipse/deeplearning4j/issues/8344
> 
> Until this has been resolved, using the "standard" (non-TF) Keras - which is well tested - is one workaround.
> Also using SameDiff's TensorFlow import support is another workaround (from TF frozen models).

---

<div class="post-metadata">

**Author:** ![lln](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lln](https://community.konduit.ai/u/lln)\
**Post date:** [March 13, 2020, 10:27am UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/3 "2020-03-13T10:27:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [March 13, 2020, 10:29am UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/4 "2020-03-13T10:29:35Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![lln](https://avatars.discourse-cdn.com/v4/letter/l/ecae2f/32.png) [@lln](https://community.konduit.ai/u/lln)\
**Post date:** [March 19, 2020, 5:09pm UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/5 "2020-03-19T17:09:02Z")

</div>

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](https://github.com/eclipse/deeplearning4j/issues/8710))

Is inceptionV3 not supported?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [March 19, 2020, 5:22pm UTC](https://community.konduit.ai/t/error-importing-tf-keras-xception-model/232/6 "2020-03-19T17:22:50Z")

</div>

Unfortunately, the `FusedBatchNormV3` op is currently not supported.
