简体   繁体   中英

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

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'] .

anyone knows?

This notebook uses inspect unit to assign proper scorer arguments, and it seems the api has changed since the notebook was published. 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. Using inspect.getfullargspec(metric_fn).kwonlyargs instead should fix the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM