Open stroebel opened 1 year ago
I think these imports were the earlier locations for these libraries. This import is fine for pytorch_lightning==2.0.6
What version of ISLP/ISLP_labs
are you trying to run this on and encountering errors? Do you have a traceback?
In terms of pinning libraries, this is what tags on ISLP_labs
will do, though I see these have somehow become unpinned on v2
: https://github.com/intro-stat-learning/ISLP_labs/blob/v2/requirements.txt.
This is the frozen version for v2
https://github.com/intro-stat-learning/ISLP_labs/blob/v2_devel/requirements.txt -- when we push a new tag I will ensure that the requirements are frozen once again.
I managed to some of the way through the Ch10 lab using the changes that I recommended above. I hit a roadblock again with lightning requiring Accuracy
to be passed a positional argument.
It looks like I am a few patch versions behind for ISLP, I will update and see if that fixes my issue.
TypeError Traceback (most recent call last)
[/Volumes/untitled/tx/learning/deep_learning.py](https://file+.vscode-resource.vscode-cdn.net/Volumes/untitled/tx/learning/deep_learning.py) in line 2
[167](file:///Volumes/untitled/tx/learning/deep_learning.py?line=166) # %%
----> [168](file:///Volumes/untitled/tx/learning/deep_learning.py?line=167) mnist_module = SimpleModule.classification(mnist_model)
[169](file:///Volumes/untitled/tx/learning/deep_learning.py?line=168) mnist_logger = CSVLogger("logs", name="MNIST")
File [~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216](https://file+.vscode-resource.vscode-cdn.net/Volumes/untitled/tx/learning/~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216), in SimpleModule.classification(model, metrics, device, **kwargs)
[214](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=213) loss = nn.CrossEntropyLoss()
[215](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=214) if 'accuracy' not in metrics:
--> [216](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=215) metrics['accuracy'] = Accuracy()
[217](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=216) if device is not None:
[218](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=217) for key, metric in metrics:
TypeError: Accuracy.__new__() missing 1 required positional argument: 'task'
ps. Thank you for your book. I have worked through the rest of the labs and they are great.
This is another difference introduced since the PDF was built. You seem to have newer versions of torch
libraries than ISLP
Try a fresh conda environment with these requirements:
https://github.com/intro-stat-learning/ISLP_labs/blob/v2.1/requirements.txt
Alternatively, pip install -U ISLP
should give you a version that rubs with the newer torch libs
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Jaco Stroebel @.> Sent: Monday, August 21, 2023 2:59:20 AM To: intro-stat-learning/ISLP @.> Cc: Jonathan Taylor @.>; Comment @.> Subject: Re: [intro-stat-learning/ISLP] rank_zero_only moved to lightning.fabric.utilities.rank_zero (Issue #2)
I managed to some of the way through the Ch10 lab using the changes that I recommended above. I hit a roadblock again with lightning requiring Accuracy to be passed a positional argument.
It looks like I am a few patch versions behind for ISLP, I will update and see if that fixes my issue.
[image]https://user-images.githubusercontent.com/5149902/261988209-de44a1f6-a0df-4e72-b77f-b8f6f3bdf4e5.png [image] https://user-images.githubusercontent.com/5149902/261988463-19f5626d-a1ba-4276-ada3-4b8a97aef9bd.png
TypeError Traceback (most recent call last) /Volumes/untitled/tx/learning/deep_learning.py in line 2 167 # %% ----> 168 mnist_module = SimpleModule.classification(mnist_model) 169 mnist_logger = CSVLogger("logs", name="MNIST")
File ~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216, in SimpleModule.classification(model, metrics, device, **kwargs) 214 loss = nn.CrossEntropyLoss() 215 if 'accuracy' not in metrics: --> 216 metrics['accuracy'] = Accuracy() 217 if device is not None: 218 for key, metric in metrics:
TypeError: Accuracy.new() missing 1 required positional argument: 'task'
ps. Thank you for your book. I have worked through the rest of the labs and they are great.
— Reply to this email directly, view it on GitHubhttps://github.com/intro-stat-learning/ISLP/issues/2#issuecomment-1686024438, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACTM2YPR6YGULH2OT4GAW3XWMWPRANCNFSM6AAAAAA3FFHLFA. You are receiving this because you commented.Message ID: @.***>
BTW, there is also a forum at statlearning.com
that has some of these issues.
I think issues on GitHub is easier but some may pop up there as well.
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Jonathan E. Taylor @.> Sent: Monday, August 21, 2023 11:31:22 AM To: intro-stat-learning/ISLP @.>; intro-stat-learning/ISLP @.> Cc: Jonathan Taylor @.>; Comment @.***> Subject: Re: [intro-stat-learning/ISLP] rank_zero_only moved to lightning.fabric.utilities.rank_zero (Issue #2)
This is another difference introduced since the PDF was built. You seem to have newer versions of torch
libraries than ISLP
Try a fresh conda environment with these requirements:
https://github.com/intro-stat-learning/ISLP_labs/blob/v2.1/requirements.txt
Alternatively, pip install -U ISLP
should give you a version that rubs with the newer torch libs
Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Jaco Stroebel @.> Sent: Monday, August 21, 2023 2:59:20 AM To: intro-stat-learning/ISLP @.> Cc: Jonathan Taylor @.>; Comment @.> Subject: Re: [intro-stat-learning/ISLP] rank_zero_only moved to lightning.fabric.utilities.rank_zero (Issue #2)
I managed to some of the way through the Ch10 lab using the changes that I recommended above. I hit a roadblock again with lightning requiring Accuracy to be passed a positional argument.
It looks like I am a few patch versions behind for ISLP, I will update and see if that fixes my issue.
[image]https://user-images.githubusercontent.com/5149902/261988209-de44a1f6-a0df-4e72-b77f-b8f6f3bdf4e5.png [image] https://user-images.githubusercontent.com/5149902/261988463-19f5626d-a1ba-4276-ada3-4b8a97aef9bd.png
TypeError Traceback (most recent call last) /Volumes/untitled/tx/learning/deep_learning.py in line 2 167 # %% ----> 168 mnist_module = SimpleModule.classification(mnist_model) 169 mnist_logger = CSVLogger("logs", name="MNIST")
File ~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216, in SimpleModule.classification(model, metrics, device, **kwargs) 214 loss = nn.CrossEntropyLoss() 215 if 'accuracy' not in metrics: --> 216 metrics['accuracy'] = Accuracy() 217 if device is not None: 218 for key, metric in metrics:
TypeError: Accuracy.new() missing 1 required positional argument: 'task'
ps. Thank you for your book. I have worked through the rest of the labs and they are great.
— Reply to this email directly, view it on GitHubhttps://github.com/intro-stat-learning/ISLP/issues/2#issuecomment-1686024438, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACTM2YPR6YGULH2OT4GAW3XWMWPRANCNFSM6AAAAAA3FFHLFA. You are receiving this because you commented.Message ID: @.***>
https://github.com/intro-stat-learning/ISLP/blob/bd0af3474fb4b6306c749a194b350199cd332a49/ISLP/torch/lightning.py#L17C51-L17C51
The fix for this is possibly to pin
pytorch_lightning
to <2.0 or to change the import tofrom pytorch_lightning.utilities.rank_zero import rank_zero_only
.I can confirm that the import at that location works. I haven't tested it against the lab for Ch10 yet though.
There is a similar issue for the
seed_everything
import for ch10. That can be handled by installing the entire lightning package and changing the import tofrom lightning_fabric.utilities.seed import seed_everything
. Pinningpytorch_lightning
might be the better course of action in this case.