GRU4REC-pytorch icon indicating copy to clipboard operation
GRU4REC-pytorch copied to clipboard

Evaluation does not reset hidden states.

Open lyf-1 opened this issue 4 years ago • 1 comments

        with torch.no_grad():
            hidden = self.model.init_hidden()
            for ii, (input, target, mask) in tqdm(enumerate(dataloader), total=len(dataloader.dataset.df) // dataloader.batch_size, miniters = 1000):
            #for input, target, mask in dataloader:
                input = input.to(self.device)
                target = target.to(self.device)
                logit, hidden = self.model(input, hidden)
                logit_sampled = logit[:, target.view(-1)]
                loss = self.loss_func(logit_sampled)
                recall, mrr = lib.evaluate(logit, target, k=self.topk)

Hi, lib.evaluation.Evaluation does not reset hidden staes. Is that right?

lyf-1 avatar Nov 28 '20 08:11 lyf-1

@lyf-1 Sorry for my late reply, Yes, you are right, lib.evaluation.Evaluation does not reset hidden staes. I think that hidden state should be reseted before the input goes through the model. Thank you for your question!

hungpthanh avatar Dec 07 '20 03:12 hungpthanh