VAE on Cifar10 dataset using CNN

username: Ravi_Gupta
cooked: <p>I got stuck due to this error. I try to resolve it in many ways but I can’t.<br>
Please anyone help me to solve it effectively</p>
<p>link of code:- <a href="https://drive.google.com/open?id=1SqN6ruqdmWg_Y7rd_S_n-bKTtCACDKkr" class="inline-onebox" rel="noopener nofollow ugc">Google Colab</a></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/e/e339704875d9e793270ee8e116946c3d11c8cfed.png" data-download-href="https://discuss.pytorch.org/uploads/default/e339704875d9e793270ee8e116946c3d11c8cfed" title="error"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/e/e339704875d9e793270ee8e116946c3d11c8cfed_2_690x329.png" alt="error" data-base62-sha1="wq7rJWLtlP2d9LFtTOtFCfZTJ49" width="690" height="329" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/e/e339704875d9e793270ee8e116946c3d11c8cfed_2_690x329.png, https://discuss.pytorch.org/uploads/default/optimized/2X/e/e339704875d9e793270ee8e116946c3d11c8cfed_2_1035x493.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/e/e339704875d9e793270ee8e116946c3d11c8cfed_2_1380x658.png 2x" data-dominant-color="F7F7F8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">error</span><span class="informations">1790×855 57.4 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Most likely this error is thrown because <code>esp</code> is still on the CPU while <code>mu</code> and <code>std</code> seem to be calculated by the linear layers and might thus be on the GPU (if the model was pushed to the GPU of course).</p>
<p>Try to create <code>esp</code> using the <code>device</code> argument of <code>mu</code>:</p>
<pre><code class="lang-python">esp = torch.randn(*mu.size(), device=mu.device)
</code></pre>

username: Ravi_Gupta
cooked: <p>Thank u for solution…it solve my error very easily…</p>

username: Ravi_Gupta
cooked: <p>Can u pls tell me why my loss is coming negative. And my output is very bad…any suggestion.</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/c/cffda94ad07f14cc3ca7aac7ebfc4f434a009592.png" data-download-href="https://discuss.pytorch.org/uploads/default/cffda94ad07f14cc3ca7aac7ebfc4f434a009592" title="tran_op"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/c/cffda94ad07f14cc3ca7aac7ebfc4f434a009592_2_690x314.png" alt="tran_op" data-base62-sha1="tFYiNwK6liVi3SlYDbH0AYysxX4" width="690" height="314" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/c/cffda94ad07f14cc3ca7aac7ebfc4f434a009592_2_690x314.png, https://discuss.pytorch.org/uploads/default/optimized/2X/c/cffda94ad07f14cc3ca7aac7ebfc4f434a009592_2_1035x471.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/c/cffda94ad07f14cc3ca7aac7ebfc4f434a009592_2_1380x628.png 2x" data-dominant-color="F5F5F5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">tran_op</span><span class="informations">1486×678 58.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/0/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9.png" data-download-href="https://discuss.pytorch.org/uploads/default/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9" title="output"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/0/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9_2_690x377.png" alt="output" data-base62-sha1="1vYKEZXaAwdAwE2Zcq7NXqwjalz" width="690" height="377" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/0/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9_2_690x377.png, https://discuss.pytorch.org/uploads/default/optimized/2X/0/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9_2_1035x565.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/0/0a9f9df5493ceff97c8a2c32c58d0405e96ccbc9_2_1380x754.png 2x" data-dominant-color="CACAC9"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">output</span><span class="informations">1405×768 133 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>