AICPS/hw2vec

why use both log_softmax and CrossEntropyLoss ?

Closed this issue · 0 comments

def train_epoch_tj(self, data):
    output, _ = self.model.embed_graph(data.x, data.edge_index, data.batch)
    output = self.model.mlp(output)
    output = F.log_softmax(output, dim=1)

    loss_train = self.loss_func(output, data.label)
    return loss_train

def __init__(self, cfg, class_weights=None):
    super().__init__(cfg)
    self.task = "TJ"
    if class_weights.shape[0] < 2:
        self.loss_func = nn.CrossEntropyLoss()
    else:    
        self.loss_func = nn.CrossEntropyLoss(weight=class_weights.float().to(cfg.device))

That means using double logsoftmax, which might introduce some negative effects.