[英]Errors in Multi class image classification using CNN
我對 CNN 和 python 相當陌生,我正在嘗試對由 3 個類組成的圖像進行分類。 每當我嘗試訓練我的模型時,我都會收到錯誤消息:TypeError:無法將 0.6 轉換為 dtype int64 的 EagerTensor。 我不完全確定該怎么做或如何解決它,並希望得到任何幫助。
這是代碼:
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
)
如果batch_size
大於total_validate
或total_train
,則steps_per_epoch
將小於 1,這會導致此'TypeError: Cannot convert 0.6 to EagerTensor of dtype int64'
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.