-
Notifications
You must be signed in to change notification settings - Fork 172
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
Problem running Test_only mode #24
Comments
Hi, Thanks for discovering this bug! I am not sure how come this was working before and not now (maybe a combination of the specific configuration you tried and how different torch versions handle things), but the solution is thankfully very simple. The problem with the existing code is that the output nodes are still part of the computational graph that is used for backpropagating loss gradients (although this is not actually used here, we don't want to update parameters, we only use predictions for evaluation).
To keep it consistent with how validation is done, instead of changing the
This should be enough, but if for whatever reason it doesn't work, then you can use the second way: that is, the I will push a fix sometime soon, but try it and let me know how it worked for you. |
Thanks for the quick reply! I have now tried out your recommended fixes. For whatever reason your first idea of adding I did end up running into another small issue after that fix though. Line 199: With those changes the test_only mode now works flawlessly for me! |
@stasj145 Thanks. I encountered the same issues with my own data and solved with exactly the same fixes. |
I can confirm as well this fixes the issue. I've pushed the recommended changes to my fork here: https://github.com/richarddli/mvts_transformer/tree/sktime0.22, which also has some minor patches to run on modern sktime etc. (see this draft #56). |
Hi George, really like the project! I have been trying it out for a couple weeks now, training multiple models including some with my own datasets. However during all this time, while training works without any problems, i have not been able to get the test_only mode running. I continue to get this error:
per_batch['predictions'].append(predictions.cpu().numpy()) RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
I have used the following commands:
Training:
python src/main.py --output_dir .\experiments --comment "regression from Scratch" --name custom_regression --records_file Regression_records.xls --data_dir ..\Datasets\CUSTOM --data_class tsra --pattern TRAIN --val_pattern TEST --epochs 100 --lr 0.001 --optimizer RAdam --pos_encoding learnable --task regression
Testing (not working):
python src/main.py --output_dir .\experiments --comment "regression from Scratch" --name Custom_regression --records_file Regression_records.xls --data_dir ..\Datasets\CUSTOM --data_class tsra --pattern TRAIN --val_pattern TEST --epochs 100 --lr 0.001 --optimizer RAdam --pos_encoding learnable --task regression --test_pattern TEST --test_only testset --load_model ./experiments/custom_regression_2022-10-20_17-05-04_MjH/checkpoints/model_best.pth
I have also tried the exact commands mentioned in this issue, which seem to work for the user that opened that issue, yet i still get the same error.
I have tested with both python 3.7 and 3.8 with the normal requirements.txt as well as the failsafe_requirements.txt. (using anaconda)
At this point i am unsure what i am doing wrong and what else to try to get the test_only mode working.
The text was updated successfully, but these errors were encountered: