Convert a model in .h5 format
Hi@loubnabnlI read yourarticleand after that I trained the model in keras this error pop up:NotImplementedError: Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using save_weights.So it doesn’t let me save the model into a “.h5” file or tensorflowLight.Can you please help me with it? How can I do the conversation in one of these two file?I’m using a VisualTransformer.
2022-07-28T16:17:30Z
How are you trying to save the model?
2022-08-01T18:53:23Z
@philschmidin these 3 ways:model_directory = “drive/MyDrive/Tirocinio/1ris_vit-stanford-dog-dataset”tokenizer = ViTFeatureExtractor.from_pretrained(model_directory)model = ViTForImageClassification.from_pretrained(model_directory)pytorch_path = “drive/MyDrive/Tirocinio/ViT_model_pytorch”model_pytorch = ViTForImageClassification.from_pretrained(pytorch_path)h5_path = “drive/MyDrive/Tirocinio/ViT_model_tf”model_h5 = ViTForImageClassification.from_pretrained(h5_path, from_tf=True)The point is that I want to save the model into an unique “.h5” file.