Spaces:
Sleeping
Sleeping
somethingbyai
commited on
Commit
•
2f0bb23
1
Parent(s):
5801159
Create model_probit.py
Browse files- model_probit.py +43 -0
model_probit.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import torch.optim as optim
|
3 |
+
import torch.nn as nn
|
4 |
+
import torch.nn.functional as F
|
5 |
+
|
6 |
+
class latent_space_old(nn.Module):
|
7 |
+
def __init__(self):
|
8 |
+
super().__init__()
|
9 |
+
|
10 |
+
self.relu = nn.ReLU()
|
11 |
+
# self.fc1 = nn.Linear(28 * 28, 20)
|
12 |
+
# self.fc2 = nn.Linear(20, 2)
|
13 |
+
self.fc = nn.Linear(2,2)
|
14 |
+
# self.final = nn.BCEWithLogitsLoss()
|
15 |
+
self.flatten = nn.Flatten()
|
16 |
+
|
17 |
+
def forward(self, x):
|
18 |
+
x = self.flatten(x)
|
19 |
+
x = self.fc(x)
|
20 |
+
x = self.final(x)
|
21 |
+
return x
|
22 |
+
|
23 |
+
class latent_space(nn.Module):
|
24 |
+
def __init__(self):
|
25 |
+
super().__init__()
|
26 |
+
|
27 |
+
self.relu = nn.ReLU()
|
28 |
+
# self.fc1 = nn.Linear(28 * 28, 20)
|
29 |
+
# self.fc2 = nn.Linear(20, 2)
|
30 |
+
self.fc = nn.Linear(2,1)
|
31 |
+
# self.fc20 = nn.Linear(10,1)
|
32 |
+
# self.final = nn.BCEWithLogitsLoss()
|
33 |
+
self.activation = nn.Sigmoid()
|
34 |
+
self.flatten = nn.Flatten()
|
35 |
+
self.relu = nn.ReLU()
|
36 |
+
|
37 |
+
def forward(self, x):
|
38 |
+
# x = self.flatten(x)
|
39 |
+
x = self.fc(x)
|
40 |
+
# x = self.relu(self.fc20(x))
|
41 |
+
x = self.relu(x)
|
42 |
+
x = self.activation(x)
|
43 |
+
return x
|