Skip to content

Commit

Permalink
Fix AssertionError at training time in vae.py (closes #191) (#192)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wisclmy0611 authored Aug 19, 2020
1 parent ebe9304 commit 35ca786
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/vae.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ 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)
zs = 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

Expand Down

0 comments on commit 35ca786

Please sign in to comment.