Sketch_RNN with pytorch Issue

username: Kibum_Baek
cooked: <p>Hi I was trying the exactly same code from this github:<a href="https://github.com/alexis-jacq/Pytorch-Sketch-RNN/blob/master/sketch_rnn.py" rel="noopener nofollow ugc">https://github.com/alexis-jacq/Pytorch-Sketch-RNN/blob/master/sketch_rnn.py</a><br>
and I tried to run the cod on Jupyter notebook.</p>
<p>Still it seems to me that it doesn’t operate because at this part</p>
<pre><code class="lang-auto">if __name__=="__main__":
    model = Model()
    for epoch in range(50001):
        model.train(epoch)
</code></pre>
<p>I have an error saying</p>
<pre><code class="lang-auto">epoch 0 loss 2.6120107173919678 LR 2.6110057830810547 LKL 0.0010049500269815326
&lt;ipython-input-17-a948bd699ee2&gt;:36: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  pi = F.softmax(pi.transpose(0,1).squeeze()).view(len_out,-1,hp.M)
&lt;ipython-input-17-a948bd699ee2&gt;:42: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument.
  q = F.softmax(params_pen).view(len_out,-1,3)
&lt;ipython-input-31-a793444e3f37&gt;:66: UserWarning: torch.nn.utils.clip_grad_norm is now deprecated in favor of torch.nn.utils.clip_grad_norm_.
  nn.utils.clip_grad_norm(self.encoder.parameters(), hp.grad_clip)
&lt;ipython-input-31-a793444e3f37&gt;:67: UserWarning: torch.nn.utils.clip_grad_norm is now deprecated in favor of torch.nn.utils.clip_grad_norm_.
  nn.utils.clip_grad_norm(self.decoder.parameters(), hp.grad_clip)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-33-1aab3c2e5ccc&gt; in &lt;module&gt;
      2     model = Model()
      3     for epoch in range(50001):
----&gt; 4         model.train(epoch)

&lt;ipython-input-31-a793444e3f37&gt; in train(self, epoch)
     78         if epoch%100==0:
     79             #self.save(epoch)
---&gt; 80             self.conditional_generation(epoch)
     81 
     82     def bivariate_normal_pdf(self, dx, dy):

&lt;ipython-input-31-a793444e3f37&gt; in conditional_generation(self, epoch)
    142             hidden_cell = (hidden, cell)
    143             # sample from parameters:
--&gt; 144             s, dx, dy, pen_down, eos = self.sample_next_state()
    145             #------
    146             seq_x.append(dx)

&lt;ipython-input-31-a793444e3f37&gt; in sample_next_state(self)
    180         sigma_y = self.sigma_y.data[0,0,pi_idx]
    181         rho_xy = self.rho_xy.data[0,0,pi_idx]
--&gt; 182         x,y = sample_bivariate_normal(mu_x,mu_y,sigma_x,sigma_y,rho_xy,greedy=False)
    183         next_state = torch.zeros(5)
    184         next_state[0] = x

&lt;ipython-input-32-7b287d68c95c&gt; in sample_bivariate_normal(mu_x, mu_y, sigma_x, sigma_y, rho_xy, greedy)
      8     cov = [[sigma_x * sigma_x, rho_xy * sigma_x * sigma_y],\
      9         [rho_xy * sigma_x * sigma_y, sigma_y * sigma_y]]
---&gt; 10     x = np.random.multivariate_normal(mean, cov, 1)
     11     return x[0][0], x[0][1]
     12 

mtrand.pyx in numpy.random.mtrand.RandomState.multivariate_normal()

TypeError: ufunc 'add' output (typecode 'O') could not be coerced to provided output parameter (typecode 'd') according to the casting rule ''same_kind''
</code></pre>
<p>Would you mind if you help me out with this?</p>

username: ptrblck
cooked: <p>The error is raised by <code>numpy</code> and points towards a type mismatch (which should have raised a deprecation warning before).<br>
Check the <code>dtype</code>s of all inputs and make sure <code>np.random.multivariate_normal</code> gets the expected numpy arrays.</p>

username: Douglas-adams
cooked: <p>Hey, I’ve been trying to solve this issue for days but I’m still having difficulties. Have you found a solution to get around it? It would be of great help.</p>

username: qiang_wang
cooked: <pre><code>mu_x = mu_x.item()
mu_y = mu_y.item()
sigma_x = sigma_x.item()
sigma_y = sigma_y.item()</code></pre>