Update handler.py
Browse files- handler.py +13 -11
handler.py
CHANGED
|
@@ -8,20 +8,22 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
| 8 |
print('Device:', device)
|
| 9 |
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
# Define model class
|
| 12 |
class MyModel(nn.Module, PyTorchModelHubMixin):
|
| 13 |
|
| 14 |
-
torch.manual_seed(42)
|
| 15 |
-
|
| 16 |
-
model = nn.Sequential(
|
| 17 |
-
nn.Linear(12, 12),
|
| 18 |
-
nn.ReLU(),
|
| 19 |
-
nn.Linear(12, 6),
|
| 20 |
-
nn.ReLU(),
|
| 21 |
-
nn.Linear(6, 1),
|
| 22 |
-
nn.Sigmoid()
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
def __init__(self):
|
| 26 |
super().__init__() # Initialize nn.Module
|
| 27 |
self.model = model
|
|
|
|
| 8 |
print('Device:', device)
|
| 9 |
|
| 10 |
|
| 11 |
+
# Define model for the model class
|
| 12 |
+
|
| 13 |
+
torch.manual_seed(42)
|
| 14 |
+
|
| 15 |
+
model = nn.Sequential(
|
| 16 |
+
nn.Linear(12, 12),
|
| 17 |
+
nn.ReLU(),
|
| 18 |
+
nn.Linear(12, 6),
|
| 19 |
+
nn.ReLU(),
|
| 20 |
+
nn.Linear(6, 1),
|
| 21 |
+
nn.Sigmoid()
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
# Define model class
|
| 25 |
class MyModel(nn.Module, PyTorchModelHubMixin):
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def __init__(self):
|
| 28 |
super().__init__() # Initialize nn.Module
|
| 29 |
self.model = model
|