Reputation: 11
I'm fairly new to CNN and python and I'm trying to classify images consisting of 3 classes. Whenever I try to train my model I get the error: TypeError: Cannot convert 0.6 to EagerTensor of dtype int64. I'm not fully sure what to make of this or how to fix it and would appreciate any help.
Here's the code :
train_gen=ImageDataGenerator(rescale=1./255)
validation_gen=ImageDataGenerator(rescale=1./255)
train_generator=train_gen.flow_from_dataframe(
train_df,
"/Users/danieladegborioye/Documents/school/FIFTH YEAR/ENGR 418 Applied Machine learning /Lego_dataset_1/training/",
x_col='filename',
y_col='category',
target_size=(150,150),
class_mode="categorical",
batch_size=32
)
validation_generator=validation_gen.flow_from_dataframe(
validate_df,
"/Users/danieladegborioye/Documents/school/FIFTH YEAR/ENGR 418 Applied Machine learning /Lego_dataset_1/training/",
x_col='filename',
y_col='category',
target_size=(150,150),
class_mode="categorical",
batch_size=32
)
epochs=10
batch_size=10
history=modell.fit(
train_generator,
epochs=epochs,
validation_data=validation_generator,
validation_steps=total_validate/batch_size,
steps_per_epoch=total_train/batch_size,
callbacks=callbacks
)
Upvotes: 1
Views: 144
Reputation:
If batch_size
is greater than the total_validate
or total_train
, then steps_per_epoch
will be less than 1 which is causing this 'TypeError: Cannot convert 0.6 to EagerTensor of dtype int64'
.
Upvotes: 0