We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3ecfdeb commit dddbcdbCopy full SHA for dddbcdb
.virtual_documents/02.ipynb.py
@@ -95,4 +95,25 @@ def forward(self,X):
95
untrained_preds[0],y_test[0]
96
97
98
+loss_fn = nn.BCEWithLogitsLoss() # has the sigmoid function builtin
99
+# BCELoss() requries sigmoid to be builtin to the model itself
100
+
101
102
+optimizer = torch.optim.SGD(model_0.parameters(),lr=0.01)
103
104
105
+epochs = 100
106
+batch_size = 32
107
108
109
+# Calculate accuracy
110
+def accuracy_fn(y_true,y_preds):
111
+ correct = torch.eq(y_true,y_preds).sum().item() # gives a False True list -> Tensor no. of true > just normal no.
112
+ acc = correct/len(y_preds)*100
113
+ return acc
114
115
116
117
118
119
0 commit comments