Hello, I have a similar problem: I would like to reuse the code coming from an introductory tutorial (this one: https://pytorch.org/tutorials/beginner/nlp/deep_learning_tutorial.html 53) but with some real data.
My dataset is the IMDB movies reviews and I transform it into a bag of word representation with tf-idf entries using successively CountVectorizer and TfidfTransformer both coming from scikit-learn.
But I cannot directly use the rows of the sparse matrix I obtain because they don’t have a “dim” attribute. More precisely a row of the output of a TfidfTransformer object is of type
<1x45467 sparse matrix of type ‘<class ‘numpy.float64’>’
and you cannot give it as an input to an object of the class torch.nn.functional.linear.
Any suggestions? Could I transform my input into something like torch.sparse.FloatTensor?
By the way, I’m not trying to build the most efficient model. It is just to get comfortable with Pytorch API’s.