CNN

less than 1 minute read

Updated:

CNN shortcuts

Size

$ W = \frac{(W-F+2P)}{S} + 1 $

Same size: F = 3, P= 1, S= 1

Half the size: F = 3, P = 1, S = 2

Defining Model

import torch
import torch.nn as nn

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        
        # conv layers (conv - bn - relu - pool)
        self.conv2d = nn.Conv2d(in_channels = 1, out_channels = 2, kernel_size = 3, stride = 1, padding = 1)
        self.bn = nn.BatchNorm2d(num_features = 2)
        self.relu = nn.ReLU()
        self.pool2d = nn.MaxPool2d(kernel_size = 2)

        # linear
        self.linear = nn.Linear(in_features, out_features)
        self.sigmoid = nn.Sigmoid()
        
    def forward(self, x):
        out = x
        return out

Leave a comment