-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
30 lines (27 loc) · 831 Bytes
/
model.py
File metadata and controls
30 lines (27 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import torch
import torch.nn as nn
class PrototypicalNet(nn.Module):
def __init__(self):
super().__init__()
self.encoder = nn.Sequential(
nn.Sequential(
nn.Conv2d(1, 64, 3, padding=1),
nn.BatchNorm2d(64)
),
nn.Sequential(
nn.Conv2d(64, 64, 3, padding=1),
nn.BatchNorm2d(64)
),
nn.Sequential(
nn.Conv2d(64, 64, 3, padding=1),
nn.BatchNorm2d(64)
),
nn.Sequential(
nn.Conv2d(64, 64, 3, padding=1),
nn.BatchNorm2d(64)
)
)
def forward(self, x):
x = self.encoder(x)
x = x.mean(dim=[2, 3]) # Global Average Pooling
return x