maciejkula / spotlight

Deep recommender models using PyTorch.
MIT License
2.97k stars 421 forks source link

Goodbooks dataset #129

Closed clarencestephen closed 5 years ago

clarencestephen commented 5 years ago

When trying to train a model get this error:

RuntimeError: Expected object of type torch.IntTensor but found type torch.FloatTensor for argument #3 'other'

yemiajayi commented 5 years ago

@maciejkula

I'm also having the same issue. Any insight on how to resolve this? Thanks!

...

dataset = get_goodbooks_dataset()
train, test = random_train_test_split(dataset, random_state=np.random.RandomState(RANDOM_SEED))

...
explicit_model.fit(train)
implicit_model.fit(train)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-19-39d512ce88b7> in <module>()
----> 1 explicit_model.fit(train)
      2 implicit_model.fit(train)

/anaconda3/lib/python3.6/site-packages/spotlight/factorization/explicit.py in fit(self, interactions, verbose)
    228                 self._optimizer.zero_grad()
    229 
--> 230                 loss = self._loss_func(batch_ratings, predictions)
    231                 epoch_loss += loss.item()
    232 

/anaconda3/lib/python3.6/site-packages/spotlight/losses.py in regression_loss(observed_ratings, predicted_ratings)
    188     assert_no_grad(observed_ratings)
    189 
--> 190     return ((observed_ratings - predicted_ratings) ** 2).mean()
    191 
    192 

RuntimeError: Expected object of type torch.IntTensor but found type torch.FloatTensor for argument #3 'other'
maciejkula commented 5 years ago

Fixed in https://github.com/maciejkula/spotlight/pull/138. You'll need to pull the master to have it before I cut a release.