[英]Pytorch MNIST ResNet50 ValueError: Target is multiclass but average='binary'
https://colab.research.google.com/github/kjamithash/Pytorch_DeepLearning_Experiments/blob/master/FashionMNIST_ResNet_TransferLearning.ipynb#scrollTo=QrIm8SnsUmaK https://colab.research.google.com/github/kjamithash/Pytorch_DeepLearning_Experiments/blob/master/FashionMNIST_ResNet_TransferLearning.ipynb#scrollTo=QrIm8SnsUmaK
When I ran this code, I encountered a problem that:当我运行这段代码时,我遇到了一个问题:
ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted']
ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted']
. ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted']
。
anyone knows?有谁知道?
This notebook uses inspect
unit to assign proper scorer arguments, and it seems the api has changed since the notebook was published.此笔记本使用
inspect
单元分配正确的记分器 arguments,似乎 api 自从笔记本发布以来发生了变化。 Specifically at this point:具体到这一步:
def calculate_metric(metric_fn, true_y, pred_y):
if "average" in inspect.getfullargspec(metric_fn).args:
...
'average'
is not in the args
list anymore. 'average'
不再在args
列表中。 Using inspect.getfullargspec(metric_fn).kwonlyargs
instead should fix the issue.使用
inspect.getfullargspec(metric_fn).kwonlyargs
应该可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.