Closed wangbingnan136 closed 2 years ago
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:
AdversarialRegularization.save_weights()
to save a checkpoint and AdversarialRegularization.load_weights()
to load back a checkpoint. AdversarialRegularization.base_model.save()
to export in TensorFlow SavedModel or HDF5 format. The exported base model can be loaded back using tf.keras.models.load_model()
, and you may construct a new AdversarialRegularization
object from the loaded model. (AdversarialRegularization
class 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 newAdversarialRegularization
object from the loaded model. (AdversarialRegularization
class 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.
Cosing this issue since PR #114 is merged.
How to save the AdversarialRegularization model?