Pytorch CNN NotImplementedError
Here is my network class:
class network(nn.Module):
    def __init__(self):
        super(network, self).__init__()
        self.conv1 = nn.Conv2d(3, 32, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv2 = nn.Conv2d(32, 32, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv3 = nn.Conv2d(32, 64, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv4 = nn.Conv2d(64, 64, 3, stride=1, padding=1, padding_mode='zeros')
        self.maxpool1 = nn.MaxPool2d(2)     # 14 * 14
        self.conv5 = nn.Conv2d(64, 128, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv6 = nn.Conv2d(128, 128, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv7 = nn.Conv2d(128, 256, 3, stride=1, padding=1, padding_mode='zeros')
        self.conv8 = nn.Conv2d(256, 256, 3, stride=1, padding=1, padding_mode='zeros')
        self.maxpool2 = nn.MaxPool2d(2)     # 7 * 7
        self.gap = nn.AvgPool2d(7)
        self.fc1 = nn.Linear(256 * 1 * 1, 256)
        self.fc2 = nn.Linear(256, len(classes))

    def foward(self, x):
        x = torch.nn.ReLU(self.conv1(x))
        x = torch.nn.ReLU(self.conv2(x))
        x = torch.nn.ReLU(self.conv3(x))
        x = torch.nn.ReLU(self.conv4(x))

        x = self.maxpool1(x)

        x = torch.nn.ReLU(self.conv5(x))
        x = torch.nn.ReLU(self.conv6(x))
        x = torch.nn.ReLU(self.conv7(x))
        x = torch.nn.ReLU(self.conv8(x))

        x = self.maxpool2(x)
        x = self.gap(x)
        x = torch.nn.ReLU(self.fc1(x))
        x = torch.nn.Softmax(self.fc2(x))
        print(f&quot;output shape: {x.shape}&quot;)

        return x

Main code
network = network()
print(network)
loss = nn.CrossEntropyLoss().to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=1e-5)

for epoch in range(nb_epochs + 1):
    iter = -1
    for batch_index, sample in enumerate(dataloader):
        x_train, y_train = sample

        # Upload Dataset in GPU device
        X = x_train.to(device, dtype=torch.float)
        Y = y_train.to(device, dtype=torch.long)

        optimizer.zero_grad()
        output = network(X)
        cost = loss(output, torch.max(Y, 1)[1])
        cost.backward()
        optimizer.step()
        iter = iter + 1

        if iter % 100 == 99 or iter == dataloader.__len__():
            print(f&quot;Epoch {epoch + 1}/{nb_epochs}   &quot;
                  f&quot;Iteration {iter + 1}/{dataloader.__len__()}     &quot;
                  f&quot;Loss {str(float(cost))[0:7]}&quot;)

print('Finished Training')

PATH = './cifar10_vgg.pth'
torch.save(model.state_dict(), PATH)

And Error displayed:
Traceback (most recent call last):
    File &quot;D:/Files/works/0+Development/Python/0+DNN/0+torch_dc/tutorial_train_save.py&quot;, line 198, in &lt;module&gt;
        output = network(X)
    File &quot;C:\Users\bolero\anaconda3\lib\site-packages\torch\nn\modules\module.py&quot;, line 727, in _call_impl
        result = self.forward(*input, **kwargs)
    File &quot;C:\Users\bolero\anaconda3\lib\site-packages\torch\nn\modules\module.py&quot;, line 175, in _forward_unimplemented
        raise NotImplementedError
NotImplementedError

I just implemented a very simple Network with Pytorch, but it doesn't work.
I wrote the &quot;init&quot; function and the forward function separately.
I watched the pytorch tutorial, and I wrote code similarly in that tutorial.
What I am aware of is that when writing a network class, I should inherit nn.Module and create init and forward functions.
I know that the init function defines the layer type, and the forward function defines the actual operation part.
If anyone knows about this issue, please comment.

Note the typo in def foward(self, x):, it should be def forward(self, x):.
