报错代码显示:
InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 10 for ‘metrics/acc/Squeeze’ (op: ‘Squeeze’) with input shapes: [?,10].
错误原因:
使用稀疏分类交叉熵的损失函数,模型的真实输出值得是一个索引index而不是one hot编码,比如你给定的真实输出值应该是0而非[1, 0, 0, 0, 0]
解决办法
1 修改损失函数为:loss=‘categorical_crossentropy’,
2 还有一种就是将one-hot编码转换为索引index。