theclassofai/Multiclass_Image_Classification

InvalidArgumentError for model.fit_generator

Opened this issue · 0 comments

Kindly help me, Im working on my dissertation as complete newbie with ML and basic coding experience. Im trying to replicate your model for my paper for multi class image model. the error is as below at compiling stage for
history = model.fit_generator(train_generator,
epochs=30,
verbose=1,
validation_data=validation_generator,
callbacks = [best_model]
)

error:

Epoch 1/30

InvalidArgumentError Traceback (most recent call last)
Input In [114], in <cell line: 1>()
----> 1 history = model.fit_generator(train_generator,
2 epochs=30,
3 verbose=1,
4 validation_data=validation_generator,
5 callbacks = [best_model]
6 )

File ~\anaconda3\lib\site-packages\keras\engine\training.py:2260, in Model.fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
2249 """Fits the model on data yielded batch-by-batch by a Python generator.
2250
2251 DEPRECATED:
2252 Model.fit now supports generators, so there is no longer any need to use
2253 this endpoint.
2254 """
2255 warnings.warn(
2256 'Model.fit_generator is deprecated and '
2257 'will be removed in a future version. '
2258 'Please use Model.fit, which supports generators.',
2259 stacklevel=2)
-> 2260 return self.fit(
2261 generator,
2262 steps_per_epoch=steps_per_epoch,
2263 epochs=epochs,
2264 verbose=verbose,
2265 callbacks=callbacks,
2266 validation_data=validation_data,
2267 validation_steps=validation_steps,
2268 validation_freq=validation_freq,
2269 class_weight=class_weight,
2270 max_queue_size=max_queue_size,
2271 workers=workers,
2272 use_multiprocessing=use_multiprocessing,
2273 shuffle=shuffle,
2274 initial_epoch=initial_epoch)

File ~\anaconda3\lib\site-packages\keras\utils\traceback_utils.py:67, in filter_traceback..error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.traceback)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb

File ~\anaconda3\lib\site-packages\tensorflow\python\eager\execute.py:54, in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
52 try:
53 ctx.ensure_initialized()
---> 54 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
55 inputs, attrs, num_outputs)
56 except core._NotOkStatusException as e:
57 if name is not None:

InvalidArgumentError: Graph execution error:

Detected at node 'categorical_crossentropy/softmax_cross_entropy_with_logits' defined at (most recent call last):
File "C:\Users\Abhijeet\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
return _r