human
I am working on the file "C_lab2_NNs/Hand_Digit_with_NN_professor.ipynb".
The first task is:
5.1. Using torch nn.Module and nn.Parameter
PyTorch nn module provides many attributes and methods to make simple the implementation and training of Neural Networks. 
nn.Module and nn.Parameter allow to implement a concise network configuration, and simplify the calculation of the gradients

nn.Module is a PyTorch class that will be used to encapsulate and design a specific neural network, thus, it is central to the implementation of deep neural nets using PyTorch

nn.Parameter allow the definition of trainable network parameters. In this way, we will simplify the implementation of the training loop.

All parameters defined with nn.Parameter will have requires_grad = True

Below you can see a PyTorch fragment for the definition of a single layer perceptron (SLP) network. You can see that at least two methods need to be defined: the initialization of the network (including parameter definition and initialization), and a forward method that implements how the network produces its output for a given input pattern. Other auxiliary functions may be defined as well.
However, you can see that there is no need to implement a backward method for gradient calculation.
````
from torch import nn
class my_multiclass_net(nn.Module):
    def init(self, nin, nout):
        """This method initializes the network parameters
        Parameters nin and nout stand for the number of input parameters (features in X)
        and output parameters (number of classes)"""
        super().init()
        self.W = nn.Parameter(.1 * torch.randn(nin, nout))
        self.b = nn.Parameter(torch.zeros(nout))
def forward(self, x):
    return softmax(x @ self.W + self.b)

def softmax(t):
    """Compute softmax values for each sets of scores in t"""
    return t.exp() / t.exp().sum(-1).unsqueeze(-1)

````
You can see that by using nn.Parameter and nn.Module you can easily implement any function of your choice. However, we need to be careful about matrix dimensions and some particularities which are required to correctly operate PyTorch...
Can you write Python code for it?

=====
Can you provide a Python code to compute softmax values for each sets of scores in t"""?
assistant
#Here is Python code to compute softmax values for each sets of scores in t"""
.

from torch import nn

class my_multiclass_net(nn.Module):
    def __init__(self, nin, nout):
        """Note that now, we do not even need to initialize network parameters ourselves"""
        super().__init__()
        self.lin = nn.Linear(nin, nout)
        
    def forward(self, x):
        return self.lin(x)
    
loss_func = nn.CrossEntropyLoss()