this is my network
class ResNetWithBottleneck(nn.Module):
    def __init__(self, dim_bottleneck_layer, num_class):
        super(ResNetWithBottleneck, self).__init__()
        # base pretrained resnet
        self.base_resnet = ResNetRvLinear()
        self.base_resnet = make_pretrained_resnet50(self.base_resnet)
        # add fc_bottleneck layer
        self.dim_bottleneck_layer = dim_bottleneck_layer
        self.fc_bottleneck = nn.Linear(2048, dim_bottleneck_layer)

        self.fc_class = nn.Linear(dim_bottleneck_layer, num_class)
        self.softmax = nn.Softmax(dim=1)

        # init weight
        self.fc_bottleneck.apply(init_weights)
        self.fc_class.apply(init_weights)

    def forward(self, x):
        x = self.base_resnet(x)
        x = self.fc_bottleneck(x)
        y = self.fc_class(x)
        y = self.softmax(y)
        return x, y

when I remove function forward last y = self.softmax(y), the code runining well.
when I add the y = self.softmax(y), the loss not descent.
and I don’t know what’s the problem with me.
btw. I want know why torchvision’s net both not use softmax in the last output layer.
thanks!

addtion:
I see some information and get Loss function will calculate softmax, when you add a addtion softmax will lower loss descent(but loss will still descent).
I review some pytorch code.
in yunjey/ pytorch-tutorial 9’s GAN code 8
D = nn.Sequential(
    nn.Linear(image_size, hidden_size),
    nn.LeakyReLU(0.2),
    nn.Linear(hidden_size, hidden_size),
    nn.LeakyReLU(0.2),
    nn.Linear(hidden_size, 1),
    nn.Sigmoid())

criterion = nn.BCELoss()

why when predict a binary class should add a sigmoid funciton?
thanks!
in line 48 when predict