Skip to content

Custom methods and training configuration in subclass model not saved by ModelCheckpoint callback #80781

@lilianabrandao

Description

@lilianabrandao

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

No

Source

binary

TensorFlow version

tf 2.12.0

Custom code

Yes

OS platform and distribution

Google Colab / Windows 11

Mobile device

No response

Python version

3.8.18

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

Hi,

I'm following the tutorial in https://www.tensorflow.org/guide/keras/customizing_what_happens_in_fit to implement a subclassed model (end-to-end GAN). For that:

  • I have overridden certain methods (train_step, save).
  • I am using the ModelCheckpoint callback to save the model (generator).

The training and model saving run smoothly, but when I load the trained model:

  • The overridden methods are not accessible; instead, the methods from the parent class (tf.keras.Model) are loaded.
    image
  • The training configuration is also not available.
    image

I attempted the fix suggested in https://github.com/tensorflow/tensorflow/issues/62450 (and the related suggestions mentioned there), but without success.

Standalone code to reproduce the issue

https://colab.research.google.com/drive/19tc4EY_wI66ZZBeLlhs0rqIyfQIKENhd#scrollTo=OM_MBvzrtm_z

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

TF 2.12For issues related to Tensorflow 2.12comp:kerasKeras related issuesstat:awaiting responseStatus - Awaiting response from authortype:supportSupport issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions