Browse Source

Added basic CNN

Basic implimentation of a CNN using pytorch.
1 converlutional layer:
-> input depth 3
-> output depth 16
-> kernel size 3
-> padding 1

1 maxpool layer
pull/21/head
elias 5 years ago
parent
commit
2b127f1486
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      ML Cookbook/CNNs/BasicCNN.py

+ 16
- 0
ML Cookbook/CNNs/BasicCNN.py View File

@ -0,0 +1,16 @@
import torch.nn as nn
import torch.nn.functional as F
# CNN architecture definition
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# convolutional layer
self.conv1 = nn.Conv2d(3, 16, 3, padding=1)
# max pooling layer
self.pool = nn.MaxPool2d(2, 2)
def forward(self, x):
# add sequence of convolutional and max pooling layers
x = self.pool(F.relu(self.conv1(x)))
return x

Loading…
Cancel
Save