Skip to content

Instantly share code, notes, and snippets.

@denisrasulev
Created January 30, 2019 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denisrasulev/8fc84d1fe2858eb4bfecd585e33608d9 to your computer and use it in GitHub Desktop.
Save denisrasulev/8fc84d1fe2858eb4bfecd585e33608d9 to your computer and use it in GitHub Desktop.
import torch
from torch import nn
cl_1 = nn.Conv2d(1, 64, 3)
mp_1 = nn.MaxPool2d(2)
cl_2 = nn.Conv2d(64, 128, 3)
mp_2 = nn.MaxPool2d(2)
cl_3 = nn.Conv2d(128, 512, 3)
mp_3 = nn.MaxPool2d(2)
cl_4 = nn.Conv2d(512, 512, 3)
mp_4 = nn.MaxPool2d(2)
input = torch.randn(1, 1, 48, 48)
out_1 = mp_1(cl_1(input))
out_1.size()
out_2 = mp_2(cl_2(out_1))
out_2.size()
out_3 = mp_3(cl_3(out_2))
out_3.size()
out_4 = mp_4(cl_4(out_3))
out_4.size()
out = cl_4(cl_3(cl_2(cl_1(input))))
out = mp_2(cl_4(cl_3(mp_1(cl_2(cl_1(input))))))
model = nn.Sequential(
nn.Conv2d(1, 64, 3),
nn.BatchNorm2d(64),
nn.ReLU(),
nn.MaxPool2d(2),
nn.Dropout(p=0.25),
nn.Linear(33856, 1472),
nn.Linear(1472, 512),
nn.Linear(512, 10),
nn.LogSoftmax(dim=1)
)
model = nn.Sequential(
nn.Conv2d(1, 64, 3),
nn.ReLU(),
nn.MaxPool2d(2),
nn.Linear(33856, 1472),
nn.Linear(1472, 512),
nn.ReLU(),
nn.Dropout(p=0.25),
nn.Linear(512, 10),
nn.LogSoftmax(dim=1)
)
ln_1 = nn.Linear(1, 512)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment