【问题标题】:ValueError: Error when checking target : expected dense_4 to have shape (4, ) but got array with shape (1, )ValueError:检查目标时出错:预期dense_4的形状为(4,)但得到的数组形状为(1,)
【发布时间】:2023-03-25 02:52:01
【问题描述】:

我已经为我自己的数据集尝试了这个模型(“https://github.com/LZQthePlane/Online-Realtime-Action-Recognition-based-on-OpenPose”)(我已经给出了坐姿动作视频并转换为 csv 文件)。 CSV 文件包含 1000 条记录。 现在在 action_enum.py 我只有 sat action 。 在 train.py 文件中,我更改了

encoder_Y = [0]*744 + [1]*722 + [2]*815 + [3]*1008

encoder_Y = [0]*1000(仅用于坐姿)。 更改 train.py 文件后,出现此错误。

【问题讨论】:

    标签: python pose-estimation openpose


    【解决方案1】:

    因为你只有一个类,你应该改变你的模型只输出一个值。

    Action/training/train.py:

    # build keras model
    model = Sequential()
    model.add(Dense(units=128, activation='relu'))
    model.add(BatchNormalization())
    model.add(Dense(units=64, activation='relu'))
    model.add(BatchNormalization())
    model.add(Dense(units=16, activation='relu'))
    model.add(BatchNormalization())
    # change 4 to 1
    model.add(Dense(units=1, activation='softmax'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-03
      • 2021-06-30
      • 2018-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-24
      • 2018-09-30
      相关资源
      最近更新 更多