簡體   English   中英

使用 CNN 進行多類圖像分類的錯誤

[英]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_validatetotal_train ,則steps_per_epoch將小於 1,這會導致此'TypeError: Cannot convert 0.6 to EagerTensor of dtype int64'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM