- class recbole.evaluator.collector.Collector(config)¶
The collector is used to collect the resource for evaluator. As the evaluation metrics are various, the needed resource not only contain the recommended result but also other resource from data and model. They all can be collected by the collector during the training and evaluation process.
This class is only used in Trainer.
Collect the evaluation resource from training data. :param train_data: the training dataloader which contains the training data. :type train_data: AbstractDataLoader
- eval_batch_collect(scores_tensor: Tensor, interaction, positive_u: Tensor, positive_i: Tensor)¶
Collect the evaluation resource from batched eval data and batched model output. :param scores_tensor: the output tensor of model with the shape of (N, ) :type scores_tensor: Torch.Tensor :param interaction: batched eval data. :type interaction: Interaction :param positive_u: the row index of positive items for each user. :type positive_u: Torch.Tensor :param positive_i: the positive item id for each user. :type positive_i: Torch.Tensor
- eval_collect(eval_pred: Tensor, data_label: Tensor)¶
Collect the evaluation resource from total output and label. It was designed for those models that can not predict with batch. :param eval_pred: the output score tensor of model. :type eval_pred: torch.Tensor :param data_label: the label tensor. :type data_label: torch.Tensor
Get all the evaluation resource that been collected. And reset some of outdated resource.
- model_collect(model: Module)¶
Collect the evaluation resource from model. :param model: the trained recommendation model. :type model: nn.Module