Error when using sparse tensor as input to module

I currently have my data defined as:

X = Variable(X_train_tensor)
y = Variable(y_train_tensor)

where X_train_tensor is a sparse FloatTensor and y_train_tensor is just 0’s and 1’s.

If have a module defined as:

class MyModule(nn.Module):
    def __init__(self, num_labels, vocab_size, nonlin=F.relu, num_units=10):
        super(MyModule, self).__init__()

        self.dense0 = nn.Linear(vocab_size, num_units)

        self.nonlin = nonlin
        self.dropout = nn.Dropout(0.5)
        self.dense1 = nn.Linear(num_units, 10)
        self.output = nn.Linear(10, num_labels)
        
    def forward(self, X, **kwargs):
        X = self.nonlin(self.dense0(X))
        X = self.dropout(X)
        X = F.relu(self.dense1(X))
        X = F.softmax(self.output(X), dim=-1)
        return X

and I’m starting the train cycle with:

for epoch in range(1):
    optimizer.zero_grad()
    outputs = model(X)

But I get the error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-258-d820af66121f> in <module>()
      1 for epoch in range(1):
      2     optimizer.zero_grad()
----> 3     outputs = model(X)

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    355             result = self._slow_forward(*input, **kwargs)
    356         else:
--> 357             result = self.forward(*input, **kwargs)
    358         for hook in self._forward_hooks.values():
    359             hook_result = hook(self, input, result)

<timed exec> in forward(self, X, **kwargs)

~\Anaconda3\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    355             result = self._slow_forward(*input, **kwargs)
    356         else:
--> 357             result = self.forward(*input, **kwargs)
    358         for hook in self._forward_hooks.values():
    359             hook_result = hook(self, input, result)

~\Anaconda3\lib\site-packages\torch\nn\modules\linear.py in forward(self, input)
     53 
     54     def forward(self, input):
---> 55         return F.linear(input, self.weight, self.bias)
     56 
     57     def __repr__(self):

~\Anaconda3\lib\site-packages\torch\nn\functional.py in linear(input, weight, bias)
    833     if input.dim() == 2 and bias is not None:
    834         # fused op is marginally faster
--> 835         return torch.addmm(bias, input, weight.t())
    836 
    837     output = input.matmul(weight.t())

RuntimeError: size is not implemented for type torch.sparse.FloatTensor

Is is possible to use sparse Tensors in this way? I’m not able to fit the dense format in memory during training.