You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to implement the model presented in Denil, Misha, et al. to model documents and sentences. I want to create embeddings for sentences and then apply some convolutional layers in order to extract relevant features. I started with this model:
Apparently the problem is due to the LookupTable module that I have after a ParallelTable module because if I replace the lookup table with a linear layer it works fine.
How do you think I can solve it? Am I doing something wrong?
Thank you in advance for your help
The text was updated successfully, but these errors were encountered:
LookupTabledoesn't have an updateGradInput method (it doesn't compute the gradients wrt the input), so the gradInput is not initialized (and by default it has 0 size), and that generates the error you are seeing.
I think one way to get around it is to replace the updateGradInput functions from all modules preceding the LookupTable to be empty functions. As you don't have parameters in the modules preceding the LookupTable, no need to compute gradients on it anyway.
In your example, it would consist of something like
-- preceeding code is the sametranspose=nn.Transpose({1, 2})
transpose.updateGradInput=function() endsp=nn.SplitTable(2)
sp.updateGradInput=function() enddocument_model=nn.Sequential()
document_model:add(transpose)
document_model:add(sp)
-- the rest is the same (but need to define input_doc to torch.Tensor(d1) !)
Hello,
I started to implement the model presented in Denil, Misha, et al. to model documents and sentences. I want to create embeddings for sentences and then apply some convolutional layers in order to extract relevant features. I started with this model:
I got the following error calling the backward method on document_model:
../lua/5.1/nn/SplitTable.lua:38: inconsistent tensor size ../torch/pkg/torch/lib/TH/generic/THTensorCopy.c:7
Apparently the problem is due to the LookupTable module that I have after a ParallelTable module because if I replace the lookup table with a linear layer it works fine.
How do you think I can solve it? Am I doing something wrong?
Thank you in advance for your help
The text was updated successfully, but these errors were encountered: