Open flyboyleo opened 4 years ago
I had the same error. There is an inconsistency in the VAE's forward() function (line 146) and how it is called in GANTrainer’s train() function (line 434), in scripts/utils_helper.py.
line 146: def forward(self, x, batch_index=None, y=None)
line 434: reconst_loss, kl_divergence, z = self.model(sample_batch, local_l_mean, local_l_var, batch_index)
.
In addition, line 434 expects 3 arguments to be returned but the forward() only returns 2 arguments, reconst_loss , kl_divergence (line 166).
Sorry for the errors. We will address this shortly. @mojtababahrami1993
Solved. It was due to some versioning of VAE class.
Thanks, @mojtababahrami1993 and @yueliyl. However, I still met some new errors when running the updated script of MDDBrianCells_scGAN.py:
RuntimeError Traceback (most recent call last)
~/PycharmProjects/scDeepFeature/scripts/MDDBrainCells_scGAN.py in
~/PycharmProjects/scDeepFeature/scripts/utils_helper.py in train(self, n_epochs, lr, eps, params, enc_lr, disc_lr) 488 self.model.zero_grad() 489 reconst_loss, kl_divergence, z = self.model(sample_batch, batch_dis) --> 490 loss = torch.mean(reconst_loss + self.model.kl_weight * kl_divergence) 491 vae_loss_list_epoch.append(loss.item()) 492 loss.backward(retain_graph=True)
RuntimeError: The size of tensor a (33694) must match the size of tensor b (128) at non-singleton dimension 1
Hello, I realise it has been quite some time since this question was asked. I was just wondering has there been any resolution to the issue? I am encountering the same problem.
Mojtaba, can you look into this? @mojtababahrami1993
I appreciate your response, I am referring to the "RuntimeError: The size of tensor a (33694) must match the size of tensor b (128) at non-singleton dimension 1" issue specifcally.
The RuntimeError: The size of tensor ...
is due to the new versions of scvi
library. Use version scvi==0.4.1
Thank you so much for your reply! I have implemented the fix, can i ask would you by chance have a list of the package versions used as I am still running into issues.
Yes sure. I will upload a clean requirements.txt file to the project. However, by then, find a little bit messy one attached here which is the output of pip freeze
: requirements.txt
Thank you very much for that. The messy version works perfectly thank you. I have unfortunately another issue:
RuntimeError
Traceback (most recent call last)
I was actually able to solve the issue myself, was an environment issue on my part. Thanks for your help, it is working as expected now!
TypeError: forward() takes from 2 to 4 positional arguments but 5 were given
when running: history = trainer.train(n_epochs=150, lr= lr1, eps=eps, disc_lr= lr 1, enc_lr = lr 0.0 ) & history = trainer.train(n_epochs=50, lr= lr1, eps=eps, disc_lr= lr 1, enc_lr = lr 0.05)
in MDDBrianCells_scGAN.py
python 3.8, Ubuntu 20.04LTS, CUDA 10.1, latest Tensorflow and Torch.