azizilab / DIISCO_public

Publically accessible code for DIISCO method
MIT License
3 stars 0 forks source link

torch tensor size error #1

Open salwanbutrus opened 9 months ago

salwanbutrus commented 9 months ago

Hello,

I am interested in testing out your tool on my data, but I am encountering the following error:

      1 predict_timepoints = torch.linspace(timepoints.min(), timepoints.max(), 100).reshape(-1, 1)
      2 f_samples_predict, W_samples_predict, y_samples_predict = \
----> 3     model.sample(predict_timepoints, n_samples=10000, include_emission_variance=True)
      4 print(y_samples_predict.shape)
      5 print(W_samples_predict.shape)

File ~/opt/anaconda3/envs/momento/lib/python3.9/site-packages/diisco/diisco.py:590, in DIISCO.sample(self, timepoints, n_samples, n_samples_per_latent, include_emission_variance)
    581     assert B_predict.shape == (
    582         n_samples_per_latent,
    583         timepoints.shape[0],
    584         self.n_cell_types,
    585         1,
    586     ), "B_predict.shape: {}".format(B_predict.shape)
    588 y_predict_mean = torch.matmul(W_predict, f_predict).squeeze(-1)
    589 y_predict_mean = (
--> 590     y_predict_mean + B_predict if self.use_bias else y_predict_mean
    591 )
    592 y_predict_cov = torch.eye(self.n_cell_types) * sigma_y**2
    593 y_predict_cov = y_predict_cov.unsqueeze(0)

RuntimeError: The size of tensor a (100) must match the size of tensor b (3) at non-singleton dimension 2

Thanks, Salwan

velezbeltran commented 9 months ago

Hello,

Thank you for the interest in DIISCO. Could you provide the shape of the data that you are using?

kunwang34 commented 9 months ago

Hi @velezbeltran , Thank you for the amazing tool. I have encountered the same error while using it. I checked the shape of y_predict_mean is torch.Size([1, 100, 7]) and B_predict torch.Size([1, 100, 7, 1]). I think this is the cause of the error. Could you please help me resolve it? Thanks, Kun

velezbeltran commented 9 months ago

Hello @kunwang34 thank you for reporting the issue and your interest in the package! This is still an "alpha" version so we are ironing out the kings of the interface, apologies for this. That being said, I spent sometime looking at the bugs and I think it should be fixed and up in the latest version in PyPI. So pip install --upgrade package_name should do the trick. Let me know if this fixes the issue.

velezbeltran commented 9 months ago

Also @salwanbutrus I think this should fix your issue too.

kunwang34 commented 9 months ago

Thanks @velezbeltran . It's very helpful.