human
I am working on the file "DL0110EN/4.1.1simple1hiddenlayer .ipynb".
The first task is:
<a id="ref1"></a>
<h2 align=center>Neural Network Module and Training Function </h2>

Define the activations and the output of the first linear layer as an attribute. Note that this is not good practice.
Can you write Python code for it?

=====
Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

class Net(nn.Module):
    def __init__(self,D_in,H,D_out):
        super(Net,self).__init__()
        self.linear1=nn.Linear(D_in,H)
        self.linear2=nn.Linear(H,D_out)
        #define the first linear layer as an attribute, this is not good practice
        self.a1=None
        self.l1=None
        
    def forward(self,x):
        self.l1=self.linear1(x)
        self.a1=F.sigmoid(self.l1)
        yhat=F.sigmoid(self.linear2(self.a1))
        return yhat