own_data_cnn_implementation_keras
own_data_cnn_implementation_keras copied to clipboard
ValueError: x and y must have same first dimension, but have shapes (20,) and (2,)
Hi Friend,
Can you help me to check this issue?
Traceback (most recent call last):
File "D:/projects-python/keras-sample/cnn/custom_data_cnn.py", line 217, in
same error I have replaced with 5 but its same error
Did anyone succeeded to handle this problem?
Even i encountered the same error.Can anyone able to solve the error??
Your error will disappear if you don't run the training with callbacks part. Just comment out
from keras import callbacks
filename='model_train_new.csv'
csv_log=callbacks.CSVLogger(filename, separator=',', append=False)
early_stopping=callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=0, verbose=0, mode='min')
filepath="Best-weights-my_model-{epoch:03d}-{loss:.4f}-{acc:.4f}.hdf5"
checkpoint = callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='min')
callbacks_list = [csv_log,early_stopping,checkpoint]
hist = model.fit(X_train, y_train, batch_size=16, nb_epoch=num_epoch, verbose=1, validation_data=(X_test, y_test),callbacks=callbacks_list)
The reason for your error is your original training has 20 epochs, but you trained again with callbacks which only trained 2 epochs. Of course there will be error.
@Coralma use numpy and if x and y are values put them in an array like np.array([])
Your error will disappear if you don't run the training with callbacks part. Just comment out
from keras import callbacks filename='model_train_new.csv' csv_log=callbacks.CSVLogger(filename, separator=',', append=False) early_stopping=callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=0, verbose=0, mode='min') filepath="Best-weights-my_model-{epoch:03d}-{loss:.4f}-{acc:.4f}.hdf5" checkpoint = callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='min') callbacks_list = [csv_log,early_stopping,checkpoint] hist = model.fit(X_train, y_train, batch_size=16, nb_epoch=num_epoch, verbose=1, validation_data=(X_test, y_test),callbacks=callbacks_list)
The reason for your error is your original training has 20 epochs, but you trained again with callbacks which only trained 2 epochs. Of course there will be error.
Thanks for your answer!- -
@tensor-flower Thanks for your answer!- -
Your error will disappear if you don't run the training with callbacks part. Just comment out
from keras import callbacks filename='model_train_new.csv' csv_log=callbacks.CSVLogger(filename, separator=',', append=False) early_stopping=callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=0, verbose=0, mode='min') filepath="Best-weights-my_model-{epoch:03d}-{loss:.4f}-{acc:.4f}.hdf5" checkpoint = callbacks.ModelCheckpoint(filepath, monitor='val_loss', verbose=1, save_best_only=True, mode='min') callbacks_list = [csv_log,early_stopping,checkpoint] hist = model.fit(X_train, y_train, batch_size=16, nb_epoch=num_epoch, verbose=1, validation_data=(X_test, y_test),callbacks=callbacks_list)
The reason for your error is your original training has 20 epochs, but you trained again with callbacks which only trained 2 epochs. Of course there will be error.
please i have a same error but i can't find the callbacks part ! where can i find the callbacks part ??
my error is :
raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (10,) and (11,)
I meet same error message,the reason is i transform two table to arrays,but i ignore that table1 has 51 rows,table2 has 50 rows. But I use same x_value for table1/2, so there is an error. It work well after i transform table1 to 50 rows.
Hi, i have the same issue, but i dont understand how to properly use callbacks.