caser_pytorch icon indicating copy to clipboard operation
caser_pytorch copied to clipboard

Padding issue, when trying to run the traning on ml1m validation set

Open miferroudjene opened this issue 3 years ago • 2 comments

I got this error when trying I run the model on /ml1m/validation/{train,test}.txt set (a.k.a validation set) , meanwhile it works just fine for /ml1m/validation/{train,test}.txt set :

Traceback (most recent call last):
  File "train_caser.py", line 335, in <module>
    model.fit(train, test, verbose=True)
  File "train_caser.py", line 181, in fit
    precision, recall, mean_aps = evaluate_ranking(self, test, train, k=[1, 5, 10])
  File "C:\Users\username\JupyterLab\caser_pytorch-master\evaluation.py", line 53, in evaluate_ranking
    test = test.tocsr()
  File "C:\Users\username\JupyterLab\caser_pytorch-master\interactions.py", line 92, in tocsr
    return self.tocoo().tocsr()
  File "C:\Users\username\JupyterLab\caser_pytorch-master\interactions.py", line 84, in tocoo
    return sp.coo_matrix((data, (row, col)),
  File "C:\Users\username\Anaconda3\envs\PT1_6\lib\site-packages\scipy\sparse\coo.py", line 196, in __init__
    self._check()
  File "C:\Users\username\Anaconda3\envs\PT1_6\lib\site-packages\scipy\sparse\coo.py", line 285, in _check
    raise ValueError('column index exceeds matrix dimensions')
ValueError: column index exceeds matrix dimensions

Is there any explanation ?

ps: it's works fine when I comment the padding code (or putting a boolean variable to False), like fellow :

def to_sequence(self, sequence_length=5, target_length=1, padding=True):
...
        # change the item index start from 1 as 0 is used for padding in sequences
        if padding:
            for k, v in self.item_map.items():
                self.item_map[k] = v + 1
            self.item_ids = self.item_ids + 1
            self.num_items += 1
...

although, I think it's totally wrong not doing the padding !

miferroudjene avatar May 09 '21 01:05 miferroudjene

Hi @MayloIFERR , sorry for the late reply. I ran the code with validation dataset while I cannot reproduce your error. From the error message, the error seems to come from scipy. Could you please use a different version of scipy (as well as pandas and numpy, I used scipy v1.2, pandas v0.24 and numpy v1.16) and see if the error go away?

Feel free to close the issue if you find a solution for it.

graytowne avatar Jun 03 '21 17:06 graytowne

I have the same problem. Have you solved it?

buptjincheng avatar Apr 14 '22 03:04 buptjincheng