Spaces:
Sleeping
Sleeping
Commit ·
8900a2d
1
Parent(s): 4f49723
premier commit
Browse files- .vscode/settings.json +4 -0
- model.py +31 -0
.vscode/settings.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"python-envs.defaultEnvManager": "ms-python.python:conda",
|
| 3 |
+
"python-envs.defaultPackageManager": "ms-python.python:conda"
|
| 4 |
+
}
|
model.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torch.nn as nn
|
| 3 |
+
import torch.nn.functional as F
|
| 4 |
+
|
| 5 |
+
class MovieposterNet(nn.Module):
|
| 6 |
+
def __init__(self):
|
| 7 |
+
super(MovieposterNet, self).__init__()
|
| 8 |
+
self.conv1 = nn.Conv2d(1,8,5)
|
| 9 |
+
self.conv2 = nn.Conv2d(8,16, 5)
|
| 10 |
+
self.pool = nn.MaxPool2d(2,2)
|
| 11 |
+
self.fc1 = nn.Linear(256,128)
|
| 12 |
+
self.fc2 = nn.Linear(128,64)
|
| 13 |
+
self.fc3 = nn.Linear(64,10)
|
| 14 |
+
|
| 15 |
+
def forward(self, x):
|
| 16 |
+
x = F.relu(self.conv1(x)) # First convolution followed by
|
| 17 |
+
x = self.pool(x) # a relu activation and a max pooling#
|
| 18 |
+
x = F.relu(self.conv2(x))
|
| 19 |
+
x = self.pool(x)
|
| 20 |
+
x=torch.flatten(x,1)
|
| 21 |
+
x = F.relu(self.fc1(x))
|
| 22 |
+
x = F.relu(self.fc2(x))
|
| 23 |
+
x = self.fc3(x)
|
| 24 |
+
return x
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def get_features(self, x):
|
| 28 |
+
x = self.pool(F.relu(self.conv1(x)))
|
| 29 |
+
x = self.pool(F.relu(self.conv2(x)))
|
| 30 |
+
x = x.view(-1, 16 * 4 * 4)
|
| 31 |
+
return x
|