20 lines
626 B
Python
20 lines
626 B
Python
import torch.nn as nn
|
|
import torch.nn.functional as F
|
|
|
|
class SimpleCNN(nn.Module):
|
|
def __init__(self):
|
|
super(SimpleCNN, self).__init__()
|
|
self.conv1 = nn.Conv2d(3, 32, kernel_size=3, padding=1)
|
|
self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1)
|
|
self.pool = nn.MaxPool2d(2, 2)
|
|
self.fc1 = nn.Linear(64 * 8 * 8, 128)
|
|
self.fc2 = nn.Linear(128, 10)
|
|
|
|
def forward(self, x):
|
|
x = self.pool(F.relu(self.conv1(x)))
|
|
x = self.pool(F.relu(self.conv2(x)))
|
|
x = x.view(-1, 64 * 8 * 8)
|
|
x = F.relu(self.fc1(x))
|
|
x = self.fc2(x)
|
|
return x
|