-
Notifications
You must be signed in to change notification settings - Fork 30
Removed deprecated torch.lstsq, replaced by torch.linalg.lstsq #33
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
Changes from all commits
f14df82
6883215
26091e4
c5b715c
2b4dd90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ def __init__(self): | |
| [0.7201, 0.8012], | ||
| [0.4062, 0.5581]]) | ||
| self.maxCRef = torch.tensor([1.9705, 1.0308]) | ||
|
|
||
| self.deprecated_torch = torch.__version__ < (1,9,0) | ||
|
|
||
| def __convert_rgb2od(self, I, Io, beta): | ||
| I = I.permute(1, 2, 0) | ||
|
|
||
|
|
@@ -49,13 +50,16 @@ def __find_concentration(self, OD, HE): | |
| Y = OD.T | ||
|
|
||
| # determine concentrations of the individual stains | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that I am not sure that doing this is backward compatible, as I believe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the Torch repo that change was made in Torch 1.9. I suggest bumping the minimum version of Torch required from 1.8 to 1.9 to assure backward compatibility:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are surprisingly many people that use older versions of pytorch and tf. Also, 1.9 isn't really that old. I think a good fix for this is to check which pytorch version that is used and introduce a if statement to handle older versions. You can get the torch version by: |
||
| return torch.lstsq(Y, HE)[0][:2] | ||
| if self.deprecated_torch: | ||
| return torch.lstsq(Y, HE)[0][:2] | ||
|
|
||
| return torch.linalg.lstsq(HE, Y)[0] | ||
|
|
||
| def __compute_matrices(self, I, Io, alpha, beta): | ||
| OD, ODhat = self.__convert_rgb2od(I, Io=Io, beta=beta) | ||
|
|
||
| # compute eigenvectors | ||
| _, eigvecs = torch.symeig(cov(ODhat.T), eigenvectors=True) | ||
| _, eigvecs = torch.linalg.eigh(cov(ODhat.T)) | ||
| eigvecs = eigvecs[:, [1, 2]] | ||
|
|
||
| HE = self.__find_HE(ODhat, eigvecs, alpha) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Just handling new/older torch version in the repo that remains :]