InvalidArgumentError (see above for traceback): targets[0] is out of range

说解决方法之前,先介绍tf.in_top_k(predictions, targets, k, name=None):

predictions:shape=[batch_size,num_classes],type.flot32
targets (the correct label): shape [batch_size], type int32 or int64

如果predictions的num_classes=2,targets=[1,3]

一般新手容易犯这个错误,细心一点就可以避开。

就是有你的输出是两类,但是你的数据集label有三类,就会报错,所以需要检查你的num_classes是否等于label的数目,比如cifar10的label=10,如果你的num_classes=9就会报错,出现这个错误只需要检查num_classes参数就行了,num_classes是你最终输出的类。




猜你喜欢

转载自blog.csdn.net/qwe2508/article/details/80561209
今日推荐