CNN-Image-Classifier icon indicating copy to clipboard operation
CNN-Image-Classifier copied to clipboard

Training Error

Open lucis13 opened this issue 6 years ago • 3 comments

I got this message in training with the train_multiclass.py file

main:14: UserWarning: Update your fit_generator call to the Keras 2 API: fit_generator(<keras.pre..., epochs=20, validation_data=<keras.pre..., callbacks=[<keras.ca..., validation_steps=300, steps_per_epoch=31) Epoch 1/20 Traceback (most recent call last):

File "", line 14, in validation_steps=validation_steps)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/models.py", line 1276, in fit_generator initial_epoch=initial_epoch)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/training.py", line 2224, in fit_generator class_weight=class_weight)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/training.py", line 1877, in train_on_batch class_weight=class_weight)

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/training.py", line 1480, in _standardize_user_data exception_prefix='target')

File "/home/cngc3/anaconda3/envs/tensorflow/lib/python3.6/site-packages/keras/engine/training.py", line 123, in _standardize_input_data str(data_shape))

ValueError: Error when checking target: expected dense_6 to have shape (3,) but got array with shape (9,)

lucis13 avatar May 16 '18 10:05 lucis13

got the same error.

BlcaKHat avatar Sep 24 '18 12:09 BlcaKHat

Any body solved this? I'm getting the same error.

Epoch 1/20 Traceback (most recent call last): File "train-multiclass.py", line 125, in validation_steps=validation_steps) File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/engine/training.py", line 1418, in fit_generator initial_epoch=initial_epoch) File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/engine/training_generator.py", line 217, in fit_generator class_weight=class_weight) File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/engine/training.py", line 1211, in train_on_batch class_weight=class_weight) File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/engine/training.py", line 789, in _standardize_user_data exception_prefix='target') File "/Users/rkaus/autodrawDataSet/cenv/lib/python2.7/site-packages/keras/engine/training_utils.py", line 138, in standardize_input_data str(data_shape)) ValueError: Error when checking target: expected dense_2 to have shape (3,) but got array with shape (2,)

kaushikmit avatar Dec 22 '18 18:12 kaushikmit

Change the variable 'classes_num' in train-multiclass.py

taejaehan avatar Jul 12 '19 11:07 taejaehan