Skip to content
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

vae.py: throwing AssertionError at training time #191

Closed
wisclmy0611 opened this issue Jul 28, 2020 · 0 comments
Closed

vae.py: throwing AssertionError at training time #191

wisclmy0611 opened this issue Jul 28, 2020 · 0 comments

Comments

@wisclmy0611
Copy link
Contributor

Hi Choy. Thanks for your great work on this project! I'm trying to train the model in vae.py. I ran python -m examples.vae --train but got the following AssertionError:

Traceback (most recent call last):
  File "/path/to/anaconda3/envs/py3-mink/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/path/to/anaconda3/envs/py3-mink/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/path/to/MinkowskiEngine/examples/vae.py", line 737, in <module>
    train(net, dataloader, device, config)
  File "/path/to/MinkowskiEngine/examples/vae.py", line 632, in train
    out_cls, targets, sout, means, log_vars, zs = net(sin, target_key)
  File "/path/to/anaconda3/envs/py3-mink/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/path/to/MinkowskiEngine/examples/vae.py", line 588, in forward
    zs += torch.exp(0.5 * log_vars.F) * torch.randn_like(log_vars.F)
  File "/path/to/MinkowskiEngine/SparseTensor.py", line 544, in __iadd__
    assert isinstance(other, SparseTensor)
AssertionError

def forward(self, sinput, gt_target):
means, log_vars = self.encoder(sinput)
zs = means
if self.training:
zs += torch.exp(0.5 * log_vars.F) * torch.randn_like(log_vars.F)
out_cls, targets, sout = self.decoder(zs, gt_target)
return out_cls, targets, sout, means, log_vars, zs

At training time, line 588 will be executed

zs += torch.exp(0.5 * log_vars.F) * torch.randn_like(log_vars.F)

while at test time it won't, so there will be no problem during inference. This error is caused by a PyTorch Tensor added to a SparseTensor. Since you have released a pretrained checkpoint,

if not os.path.exists(config.weights):
logging.info(
f'Downloaing pretrained weights. This might take a while...')
urllib.request.urlretrieve(
"https://bit.ly/39TvWys", filename=config.weights)

I assume you've successfully run the code to train a VAE. Could you please share how you have done that without encountering the error? Thanks so much!

wisclmy0611 added a commit to wisclmy0611/MinkowskiEngine that referenced this issue Jul 29, 2020
The operator += will call the __iadd__ function, which triggers a type check and fails when a PyTorch Tensor is added to a SparseTensor. This commit fixes this problem by using the + operator, which calls the __add__ function.
wisclmy0611 added a commit to wisclmy0611/MinkowskiEngine that referenced this issue Jul 29, 2020
The operator += will call the __iadd__ function, which triggers a type check and fails when a PyTorch Tensor is added to a SparseTensor. This commit fixes this problem by using the + operator, which calls the __add__ function.
Tanazzah pushed a commit to Tanazzah/MinkowskiEngine that referenced this issue Feb 9, 2024
…IDIA#192)

The operator += will call the __iadd__ function, which triggers a type check and fails when a PyTorch Tensor is added to a SparseTensor. This commit fixes this problem by using the + operator, which calls the __add__ function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant