Terence9's picture
Upload 6 files
9df438a verified
raw
history blame contribute delete
732 Bytes
import torch.nn as nn
class WasteCNN(nn.Module):
def __init__(self):
super(WasteCNN, self).__init__()
self.conv_layer = nn.Sequential(
nn.Conv2d(3, 32, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2),
nn.Conv2d(32, 64, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2),
nn.Conv2d(64, 128, 3, padding=1), nn.ReLU(), nn.MaxPool2d(2),
)
self.fc_layer = nn.Sequential(
nn.Flatten(),
nn.Linear(128 * 16 * 16, 128),
nn.ReLU(),
nn.Dropout(0.5),
nn.Linear(128, 2) # 2 classes: dry/wet
)
def forward(self, x):
x = self.conv_layer(x)
x = self.fc_layer(x)
return x