How to get backward gradients from sparse matrices in PyTorch networks?
I am following the PyTorch tutorial example:

https://pytorch.org/tutorials/beginner/pytorch_with_examples.html

The example runs without any problems, but as soon as I switched it to my own dataset (which is a sparse tensor, because it is too big to be used as a dense tensor), I run into this error:

RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-127-8b4999644085&gt; in &lt;module&gt;()
 41     # Backward pass: compute gradient of the loss with respect to model
 42     # parameters
---&gt; 43     loss.backward()
 44 
 45     # Calling the step function on an Optimizer makes an update to its

~/miniconda3/envs/py3/lib/python3.6/site-packages/torch/tensor.py in backward(self, gradient, retain_graph, create_graph)
 91                 products. Defaults to ``False``.
 92         """
---&gt; 93         torch.autograd.backward(self, gradient, retain_graph, create_graph)
 94 
 95     def register_hook(self, hook):

~/miniconda3/envs/py3/lib/python3.6/site-packages/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
 87     Variable._execution_engine.run_backward(
 88         tensors, grad_tensors, retain_graph, create_graph,
---&gt; 89         allow_unreachable=True)  # allow_unreachable flag
 90 
 91 

RuntimeError: Expected object of type torch.FloatTensor but found type torch.sparse.FloatTensor for argument #2 'mat2'


I tried switching the optimizer (Adagrad, Adam), but it doesn't seem to work. 

Edit: Added more of the error output. The error occurs on backward()

Looks like this functionality is currently being worked on now. 

https://github.com/pytorch/pytorch/issues/2389
