BISHWENDU DEY
BISHWENDU DEY

Reputation: 1

how to resolve the ValueError: Unable to create dataset (name already exists)

I already have two pretrained keras models which I have uploaded in my drive and mounted it in colab. then I have given the model paths to load the models and then I tried to do ensembling:

This is the code for model ensembling : model1 = load_model('/content/gdrive/MyDrive/models/BLOOD_CELL.hdf5') model1 = Model(inputs = model1.inputs, outputs = model1.outputs, name = 'BLOOD_CELL.hdf5')

model2 = load_model('/content/gdrive/MyDrive/models/blood_model.hdf5') model2 = Model(inputs = model2.inputs, outputs = model2.outputs, name = 'blood_model.hdf5')

models = [model1,model2] model_input = Input(shape = (274,366,3)) model_output = [model(model_input)for model in models] ensemble_output = Average()(model_output) ensemble_model = Model(inputs = model_input,outputs = ensemble_output,name = 'ensemble')

compiling the model:

optimizer = tf.keras.optimizers.legacy.Adam(learning_rate= 0.00001, decay= 1e-6) ensemble_model.compile(optimizer=optimizer, loss = 'categorical_crossentropy', metrics = ['acc'])

fitting the model:

history = ensemble_model.fit(train_generator, steps_per_epoch = len(train_generator), epochs = 2, verbose = 1, validation_steps = len(test_generator), validation_data = test_generator )

and done this to save the model where the error pops up:

ensemble_model.save('blood_ensemble.hdf5')

\>

and this is the problem I am facing while I was trying to save the model 

ValueError                                Traceback (most recent call last)
<ipython-input-23-0c7c0f24df8f> in <cell line: 1>()
----> 1 ensemble_model.save('/content/blood_ensemble.hdf5')

2 frames
/usr/local/lib/python3.10/dist-packages/h5py/_hl/dataset.py in make_new_dset(parent, shape, dtype, data, name, chunks, compression, shuffle, fletcher32, maxshape, compression_opts, fillvalue, scaleoffset, track_times, external, track_order, dcpl, dapl, efile_prefix, virtual_prefix, allow_unknown_filter, rdcc_nslots, rdcc_nbytes, rdcc_w0)
    163         sid = h5s.create_simple(shape, maxshape)
    164 
--> 165     dset_id = h5d.create(parent.id, name, tid, sid, dcpl=dcpl, dapl=dapl)
    166 
    167     if (data is not None) and (not isinstance(data, Empty)):

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5d.pyx in h5py.h5d.create()

ValueError: Unable to create dataset (name already exists)

I had also tried to save the model using check pointers.

can anybody help me please

Upvotes: 0

Views: 263

Answers (0)

Related Questions