Saving `AdversarialRegularization` models is currently not supported. Consider using `save_weights` or saving the `base_model`
wangbingnan136 opened this issue · 4 comments
How to save the AdversarialRegularization model?
I used the modelcheckpoint,and it returned the "Saving AdversarialRegularization models is currently not supported. Consider using save_weights or saving the base_model" error,I found that the "save" method of AdversarialRegularization was not implemented.
Hi @wangbingnan136, thanks for your question.
Yes, AdversarialRegularization.save() is not implemented. (PRs are more than welcome!) Depending on your use case, here are the suggested alternatives:
- For checkpointing and pausing/resuming the training, you may use
AdversarialRegularization.save_weights()to save a checkpoint andAdversarialRegularization.load_weights()to load back a checkpoint. - For exporting a trained model for evaluation and serving, you may use
AdversarialRegularization.base_model.save()to export in TensorFlow SavedModel or HDF5 format. The exported base model can be loaded back usingtf.keras.models.load_model(), and you may construct a newAdversarialRegularizationobject from the loaded model. (AdversarialRegularizationclass doesn't have any model variable, so the new object should behave the same as the original object.)
Hi @wangbingnan136, thanks for your question.
Yes,
AdversarialRegularization.save()is not implemented. (PRs are more than welcome!) Depending on your use case, here are the suggested alternatives:
- For checkpointing and pausing/resuming the training, you may use
AdversarialRegularization.save_weights()to save a checkpoint andAdversarialRegularization.load_weights()to load back a checkpoint.- For exporting a trained model for evaluation and serving, you may use
AdversarialRegularization.base_model.save()to export in TensorFlow SavedModel or HDF5 format. The exported base model can be loaded back usingtf.keras.models.load_model(), and you may construct a newAdversarialRegularizationobject from the loaded model. (AdversarialRegularizationclass doesn't have any model variable, so the new object should behave the same as the original object.)
Thanks for reply! I have pull a request already to fix the "save" bug.It's now only save the base model of adv_model.