Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: The provided metric AccuracyNovel for keeping the best model is not computed by the evaluation routine. #22

Open
vieozhu opened this issue Jul 31, 2019 · 4 comments

Comments

@vieozhu
Copy link

vieozhu commented Jul 31, 2019

Can you give me some advice about this Error?

2019-07-31 08:51:00,403 - algorithms.Algorithm - INFO   - Training: miniImageNet_Conv32CosineClassifier
 20%|█▉        | 197/1000 [00:05<00:21, 37.46it/s]2019-07-31 08:51:06,434 - algorithms.Algorithm 
100%|██████████| 1000/1000 [00:27<00:00, 35.99it/s]
2019-07-31 08:51:28,193 - algorithms.Algorithm - INFO   - ==> Training stats: {'loss': 2.469}
2019-07-31 08:51:28,200 - algorithms.Algorithm - INFO   - Evaluating: miniImageNet_Conv32CosineClassifier
2019-07-31 08:51:28,200 - algorithms.Algorithm - INFO   - ==> Dataset: MiniImageNet_val [2000 batches]
  0%|          | 0/2000 [00:00<?, ?it/s]/data1/zjj/meta-code/withoutForgetting/algorithms/FewShot.py:185: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  images_test_var = Variable(images_test, volatile=is_volatile)
/data1/withoutForgetting/algorithms/FewShot.py:190: UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
  images_train_var = Variable(images_train, volatile=is_volatile)
100%|██████████| 2000/2000 [01:14<00:00, 26.36it/s]
2019-07-31 08:52:43,083 - algorithms.Algorithm - INFO   - ==> Results: {'loss': 3.1131, 'AccuracyNovel_cnf': 0.4092}
2019-07-31 08:52:43,084 - algorithms.Algorithm - INFO   - ==> Evaluation stats: {'loss': 3.1131, 'AccuracyNovel_cnf': 0.4092}
Traceback (most recent call last):
  File "train.py", line 110, in <module>
    algorithm.solve(dloader_train, dloader_test)
  File "/data1/withoutForgetting/algorithms/Algorithm.py", line 288, in solve
    self.keep_record_of_best_model(eval_stats, self.curr_epoch)
  File "/data1/withoutForgetting/algorithms/Algorithm.py", line 359, in keep_record_of_best_model
    .format(metric_name))
ValueError: The provided metric AccuracyNovel for keeping the best model is not computed by the evaluation routine.

The error occurred in:

    def keep_record_of_best_model(self, eval_stats, current_epoch):
        if self.keep_best_model_metric_name is not None:
            metric_name = self.keep_best_model_metric_name
            if (metric_name not in eval_stats):
                raise ValueError('The provided metric {0} for keeping the best '
                                 'model is not computed by the evaluation routine.'
                                 .format(metric_name))
            metric_val = eval_stats[metric_name]

Thanks a lot!

@Lan1991Xu
Copy link

change back to pytorch version==0.4

@Franklin-Yao
Copy link

Franklin-Yao commented Nov 10, 2019

This issue is caused by different versions of pytorch. Higher versions of Pytorch will return a tensor and lower version will return the type of float for this line:
https://github.com/gidariss/FewShotWithoutForgetting/blob/master/algorithms/FewShot.py#L20
Then in the update method(https://github.com/gidariss/FewShotWithoutForgetting/blob/master/utils.py#L154), AccuracyNovel will be ignored.

@xuxf1992
Copy link

xuxf1992 commented Aug 4, 2021

This issue is caused by different versions of pytorch. Higher versions of Pytorch will return a tensor and lower version will return the type of float for this line:
https://github.com/gidariss/FewShotWithoutForgetting/blob/master/algorithms/FewShot.py#L20
Then in the update method(https://github.com/gidariss/FewShotWithoutForgetting/blob/master/utils.py#L154), AccuracyNovel will be ignored.

nice!!!

@ContestantsD
Copy link

This issue is caused by different versions of pytorch. Higher versions of Pytorch will return a tensor and lower version will return the type of float for this line: https://github.com/gidariss/FewShotWithoutForgetting/blob/master/algorithms/FewShot.py#L20 Then in the update method(https://github.com/gidariss/FewShotWithoutForgetting/blob/master/utils.py#L154), AccuracyNovel will be ignored.

Hi, bro, i use the same pytorch version like u, but i still get the error ,could you help me ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants