【问题标题】:TypeError: If class_mode="categorical", y_col column values must be type string, list or tupleTypeError: If class_mode="categorical", y_col 列值必须是字符串、列表或元组类型
【发布时间】:2020-02-09 07:03:28
【问题描述】:

keras documentation 中,提到了"categorical": 2D numpy array of one-hot encoded labels. Supports multi-label output.,但在我的情况下,它不支持。

train_generator_1 = train_data_gen.flow_from_dataframe(annotation,
                                                      directory="data",
                                                      target_size=(img_shape,img_shape),
                                                      x_col="Left",
                                                      y_col=['N','D','G','C','A','H','M','O'],
                                                      class_mode='categorical',
                                                      shuffle=False,
                                                      batch_size=batch_size,
                                                      seed=7)

附上标签图片。 我得到的错误是TypeError: If class_mode="categorical", y_col="['N', 'D', 'G', 'C', 'A', 'H', 'M', 'O']" column values must be type string, list or tuple.

【问题讨论】:

标签: python keras


【解决方案1】:

如果您有多个输出,则必须选择 class_mode 作为“原始”。 我在这里找到了 Vijayabhaskar J 的一个很棒的教程。 https://medium.com/@vijayabhaskar96/multi-label-image-classification-tutorial-with-keras-imagedatagenerator-cd541f8eaf24

【讨论】:

    猜你喜欢
    • 2015-06-11
    • 2021-11-14
    • 2021-08-06
    • 1970-01-01
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    相关资源
    最近更新 更多