Sketch_RNN with pytorch Issue

Hi I was trying the exactly same code from this github:https://github.com/alexis-jacq/Pytorch-Sketch-RNN/blob/master/sketch_rnn.py
and I tried to run the cod on Jupyter notebook.

Still it seems to me that it doesn’t operate because at this part

if __name__=="__main__":
    model = Model()
    for epoch in range(50001):
        model.train(epoch)

I have an error saying

epoch 0 loss 2.6120107173919678 LR 2.6110057830810547 LKL 0.0010049500269815326
<ipython-input-17-a948bd699ee2>: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)
<ipython-input-17-a948bd699ee2>: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)
<ipython-input-31-a793444e3f37>: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)
<ipython-input-31-a793444e3f37>: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)
<ipython-input-33-1aab3c2e5ccc> in <module>
      2     model = Model()
      3     for epoch in range(50001):
----> 4         model.train(epoch)

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

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

<ipython-input-31-a793444e3f37> 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]
--> 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

<ipython-input-32-7b287d68c95c> 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]]
---> 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''

Would you mind if you help me out with this?

The error is raised by numpy and points towards a type mismatch (which should have raised a deprecation warning before).
Check the dtypes of all inputs and make sure np.random.multivariate_normal gets the expected numpy arrays.

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.

mu_x = mu_x.item()
mu_y = mu_y.item()
sigma_x = sigma_x.item()
sigma_y = sigma_y.item()