ANIKET SAXENA
ANIKET SAXENA

Reputation: 33

Unable to create Group (no write intent on file)

I got this error everytime I load my model back from an HDF5 file. Below is my error trace.

Traceback (most recent call last):
  File "D:\Anaconda3New\Datasets\train.py", line 63, in <module>
    model = load_model(args["model"])
  File "D:\Anaconda3New\lib\site-packages\keras\engine\saving.py", line 419, in
load_model
    model = _deserialize_model(f, custom_objects, compile)
  File "D:\Anaconda3New\lib\site-packages\keras\engine\saving.py", line 249, in
_deserialize_model
    layer_weights = model_weights_group[name]
  File "D:\Anaconda3New\lib\site-packages\keras\utils\io_utils.py", line 303, in
 __getitem__
    val = H5Dict(self.data.create_group(attr))
  File "C:\Users\dell\AppData\Roaming\Python\Python37\site-packages\h5py\_hl\gro
up.py", line 68, in create_group
    gid = h5g.create(self.id, name, lcpl=lcpl, gcpl=gcpl)
  File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py\h5g.pyx", line 161, in h5py.h5g.create
ValueError: Unable to create group (no write intent on file)

I have read the below question but seems this is a different problem from what I have been through right now.

I can't read data back in using h5py. "unable to create group"

Because I am just loading my architecture and weights from my saved HDF5 file (created after pressing ctrl+c in cmd), how can I assign a mode to this HDF5 file?

Can anybody help me to resolve this issue?

Upvotes: 1

Views: 4008

Answers (2)

Salem
Salem

Reputation: 399

Give write permissions to h5py package before saving your file.

This should work : h5py.get_config().default_file_mode = "w"

Upvotes: 0

Hrishikesh Vichore
Hrishikesh Vichore

Reputation: 365

See there are two ways of saving a model. A:-

model.save("Model_name.model") and B:-

model_json = model.to_json()
with open(file_name + ".json", "w") as json_file:
        json_file.write(model_json)
model.save_weights(file_name + '.h5')

I believe you were saving the model using the first method and it does not work because of many internal clashes. I recommend that you save the model using second way and then try to reload the model. It will work.

Another possible error might be that since you are saying the model is saved after pressing ctrl + c which is usually used to terminate program and hence it may result in improper saving of file. Try some different key combo.

Upvotes: 2

Related Questions