1:将封装好的interaction数据放在损失函数里面,计算损失。
losses = loss_func(interaction)
interaction值为:
The batch_size of interaction: 2048
user_id, torch.Size([2048]), cpu, torch.int64
item_id, torch.Size([2048]), cpu, torch.int64
rating, torch.Size([2048]), cpu, torch.float32
timestamp, torch.Size([2048]), cpu, torch.float32
neg_item_id, torch.Size([2048]), cpu, torch.int64
2:调用calculate_loss函数计算损失。
def calculate_loss(self, interaction):
3:调用forward函数将用户和正样本分别表征成2048*64维矩阵。