How to implement Softmax regression with pytorch?
I am working on a uni assignment where I need to implement Softmax Regression with Pytorch. The assignment says:
Implement Softmax Regression as an nn.Module and pipe its output with its output with torch.nn.Softmax.

As I am new to pytorch, I am not sure how to do it exactly. So far I have tried:
class SoftmaxRegression(nn.Module):  # inheriting from nn.Module!
def __init__(self, num_labels, num_features):

    super(SoftmaxRegression, self).__init__()
    self.linear = torch.nn.Linear(num_labels, num_features)

def forward(self, x):
    # should return the probabilities for the classes, e.g.
    # tensor([[ 0.1757,  0.3948,  0.4295],
    #         [ 0.0777,  0.3502,  0.5721], 
    #         ...

    # not sure what to do here

does anybody have any idea how I could go about it? I am not sure what should be written in the forward method. I appreciate any help !

As far as I understand, the assignment wants you to implement your own version of the Softmax function. But, I didn't get what do you mean by and pipe its output with torch.nn.Softmax. Are they asking you to return the output of your custom Softmax along with torch.nn.Softmax from your custom nn.Module? You could do this:
class SoftmaxRegression(nn.Module):
    def __init__(self, dim=0):
        super(SoftmaxRegression, self).__init__()
        self.dim = dim
    def forward(self, x):
        means = torch.mean(x, self.dim, keepdim=True)[0]
        exp_x= torch.exp(x-means)
        sum_exp_x = torch.sum(exp_x, self.dim, keepdim=True)
        value = exp_x/sum_exp_x
        return value

