kordk / torch-ecpg

(GPU accelerated) eCpG mapper
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Typo in regression_full.py? #12

Closed kordk closed 1 year ago

kordk commented 1 year ago

I was given an error when running tecpg run mlr with the demo data that appears to be a typo. When I made the change and re-installed, it worked as expected.

# kord@pnldev [15:56:11] ~/proj/torch-ecpg-proj/torch-ecpg/tecpg $
git status .
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   regression_full.py

no changes added to commit (use "git add" and/or "git commit -a")
# kord@pnldev [15:56:13] ~/proj/torch-ecpg-proj/torch-ecpg/tecpg $
git diff regression_full.py
diff --git a/tecpg/regression_full.py b/tecpg/regression_full.py
index 9b1c58b..2c3dd77 100644
--- a/tecpg/regression_full.py
+++ b/tecpg/regression_full.py
@@ -80,8 +80,8 @@ def regression_full(
         for gene_site, G_row in G.iterrows():
             results = []
             oneX[:, 1] = torch.tensor(G_row.to_numpy()).to(device)
-            XtX = oneX.mT.matmul(oneX)
-            Xty = oneX.mT.matmul(y)
+            XtX = oneX.T.matmul(oneX)
+            Xty = oneX.T.matmul(y)
             beta = XtX.inverse().matmul(Xty)
             if include[0]:
                 results.append(beta.cpu().numpy())
kordk commented 1 year ago

This is a non-issue and due to my local installation. The error was cleared once my conda installation was updated to support tensor and the gpu fully.

/home/kord/proj/torch-ecpg-proj/torch-ecpg/tecpg/regression_full.py:90: UserWarning: The use of `x.T` on tensors of dimension other than 2 to reverse their shape is deprecated and it will throw an error in a future release. Consider `x.mT` to transpose batches of matrices or `x.permute(*torch.arange(x.ndim - 1, -1, -1))` to reverse the dimensions of a tensor. (Triggered internally at /opt/conda/conda-bld/pytorch_1667459633940/work/aten/src/ATen/native/TensorShape.cpp:3493.)
  s2 = err.T.matmul(err) / (nrows - ncols - 1)