human
I am working on the file "Neural Network/Neural network.ipynb".
The first task is:
Now lets start with the class definition
So essentially the weights in the class is the list of arrays of weights between two layers, for example if the layers = [2,3,2], that will result in the figure 1 exactly. we will have weights[0] = 3x4 matrix and weights[1] = 4x2 matrix (refer to the figure one and see how this makes sense).
Now we move to training this neural network, where we will apply an algorithm called stochastic gradient descent its is same as standard gradient descent except for the fact that it makes an update to the weight vector using a single data point at a time. These data points are either selected by cycling through the data or choosing randomly. So we have
$$\textbf{w}^{(\tau + 1)} = \textbf{w}^{(\tau)} - \eta \nabla E_n(\textbf{w}^{(\tau)}) \quad \quad \quad (15)$$
So now using the above information we can substitute the value of the gradient we found by back propogation in the stochastic gradient equation. This is what we will use to write the training function for the class.
Can you write Python program for it?

=====
Here we will use to write the training function for the class?
assistant
#Here we will use to write the training function for the class.

class neural_network:
    def __init__(self, layers):
        """
        layers: A list containing the number of units in each layer.
                Should be at least two values (this also includes the input layer)
        actfn : String to select the type of activation function
        """
        
        self.act_fn = tanh # the activation function of the hidden layers
        self.act_fn_derv = tanh_derv # the derivative of the activation function of the hidden layers
        
        self.weights = [] # list of the weights
        # now we need to initialize these weights
        # We have to keep in mind that every layer except for the output will have one extra bias unit
        # we initialize the weights randomly between [-0.5,0.5]
        
        for i in range(1,len(layers) - 1):
            self.weights.append(0.5 * (2 * np.random.random([layers[i-1] + 1, layers[i] + 1]) - 1))
        
        # and for between the last hidden layer and the output layer
        self.weights.append(0.5 * (2 * np.random.random([layers[i] + 1, layers[i + 1]]) - 1))
    
    # This is the training function
    def train(self, X, t, eta = 0.05, max_iter = 10000):
        """
        X: Training data input set X = Nxdi, di= dimension of the input data > 1, N = number of data points
        t: Training data output set, t = Nxdo , do = dimension of the output data
        eta : double
            it is the step size for the stochastic gradient descent
        max_iter : int
            Number of iterations of the gradient descent
        """
        
        # first we need to add another unit to the input
        # as the input we have provided does not have a 
        # bias input (which we set as one)
        X = np.atleast_2d(X) # google this command! it's just for smooth computation of matrices
        temp = np.ones((X.shape[0], X.shape[1] + 1))
        temp[:, 0:X.shape[1]] = X
        X = temp
        
        # Now for the stochastic gradient descent iterations
        
        for k in range(max_iter):
     ...