Upload model.py with huggingface_hub
Browse files
model.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch.nn as nn
|
| 2 |
+
import torch.nn.functional as F
|
| 3 |
+
|
| 4 |
+
class Net(nn.Module):
|
| 5 |
+
def __init__(self):
|
| 6 |
+
super().__init__()
|
| 7 |
+
self.conv1 = nn.Conv2d(3, 16, kernel_size=3, padding=1)
|
| 8 |
+
self.conv2 = nn.Conv2d(16, 8, kernel_size=3, padding=1)
|
| 9 |
+
self.fc1 = nn.Linear(8 * 64 * 64, 32) # for 256x256 input
|
| 10 |
+
self.fc2 = nn.Linear(32, 4) # 4 classes
|
| 11 |
+
|
| 12 |
+
def forward(self, x):
|
| 13 |
+
out = F.max_pool2d(torch.tanh(self.conv1(x)), 2) # 256 -> 128
|
| 14 |
+
out = F.max_pool2d(torch.tanh(self.conv2(out)), 2) # 128 -> 64
|
| 15 |
+
out = out.view(-1, 8 * 64 * 64)
|
| 16 |
+
out = torch.tanh(self.fc1(out))
|
| 17 |
+
out = self.fc2(out)
|
| 18 |
+
return out
|