AttributeError: 'OwnedIterator' object has no attribute '_get_trainable_state'

Viewed 429

I want to use quantization aware training(QAT) to quantize EfficientNet and run on Google Colaboratory.

I use its GPU(Tesla K80).

So, I change keras to tensorflow keras due to fit QAT API.

But, there is a problem when I training the model(before using QAT).

# model compilation
model_final.compile(loss='categorical_crossentropy',
              optimizer=tf.keras.optimizers.Adam(0.0001),
              metrics=['accuracy', acc_top5])
mcp_save = tf.keras.callbacks.ModelCheckpoint('EnetB7_CIFAR10_TL.h5', save_best_only=True, monitor='val_acc')
reduce_lr = tf.keras.callbacks.ReduceLROnPlateau(monitor='val_acc', factor=0.5, patience=2, verbose=1,)

model_final.fit(x_train, y_train,
              batch_size=32,
              epochs=10,
              validation_split=0.1,
              callbacks=[mcp_save, reduce_lr],
              shuffle=True,
              verbose=1)

The error is AttributeError: 'OwnedIterator' object has no attribute '_get_trainable_state'.

I don't know why I could run the code on colab two times without any change.

full traceback

Epoch 1/10
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-199bf2f08514> in <module>()
     14               callbacks=[mcp_save, reduce_lr],
     15               shuffle=True,
---> 16               verbose=1)

10 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
    966                 options=autograph.ConversionOptions(
    967                     recursive=True,
--> 968                     optional_features=autograph_options,
    969                     user_requested=True,
    970                 ))

AttributeError: in user code:

    /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:576 _reset_compile_cache  *
        self._compiled_trainable_state = self._get_trainable_state()

    AttributeError: 'OwnedIterator' object has no attribute '_get_trainable_state'
0 Answers
Related