keras损失函数踩坑

出现报错logits and labels must have the same first dimension, got logits shape [32,4] and labels shape [128],点开链接查看解决方法

报错原因:
发现我使用的label是one-hot encoding,所以不能使用sparse_categorical_crossentropy,必须使用
categorical_crossentropy 。但如果标签没有经过one-hot encoding,就可以使用sparse_categorical_crossentropy了

参考:
categorical_crossentropy 和 sparse_categorical_crossentropy的区别

上一篇:Chrome v8 类型混淆 CVE-2021-30551(只有原理上的一点理解)


下一篇:(四)Linux内存模型之Sparse Memory Model