microsoft / nni

An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
https://nni.readthedocs.io
MIT License
14.06k stars 1.82k forks source link

ValueError: num_classes must be specified for torchmetrics >= 0.11. Please either specify it or use an older version of torchmetrics. #5695

Open Kevin11Kaikai opened 1 year ago

Kevin11Kaikai commented 1 year ago

NNI 学生项目问题概述 / General Question of Student Program

请简要概述您的问题 / 观点 : Short summary about the question / idea :

请提供 NNI 环境信息 : nni Environment :

其他建议 / Other Advice

是否需要更新文档(是 / 否): Need to update document ( yes / no ) :

其他分享内容 : Anything else we need to know :

Log message / 日志信息 :

Kevin11Kaikai commented 1 year ago

ValueError: num_classes must be specified for torchmetrics >= 0.11. Please either specify it or use an older version of torchmetrics. when I am trying to run the darts tutorial in google colab, I meet the problem when I am running the block "evaluator = Classification( learning_rate=1e-3, weight_decay=1e-4, train_dataloaders=search_train_loader, val_dataloaders=search_valid_loader, max_epochs=10, gpus=1, fast_dev_run=fast_dev_run, )", the bug is "--------------------------------------------------------------------------- ValueError Traceback (most recent call last) in <cell line: 1>() ----> 1 evaluator = Classification( 2 learning_rate=1e-3, 3 weight_decay=1e-4, 4 train_dataloaders=search_train_loader, 5 val_dataloaders=search_valid_loader,

5 frames /usr/local/lib/python3.10/dist-packages/nni/nas/evaluator/pytorch/lightning.py in init(self, criterion, learning_rate, weight_decay, optimizer, export_onnx, num_classes) 334 else: 335 if num_classes is None: --> 336 raise ValueError('num_classes must be specified for torchmetrics >= 0.11. ' 337 'Please either specify it or use an older version of torchmetrics.') 338 metrics = {'acc': torchmetrics.Accuracy('multiclass', num_classes=num_classes)}

ValueError: num_classes must be specified for torchmetrics >= 0.11. Please either specify it or use an older version of torchmetrics."