Skip to content

Commit dddbcdb

Browse files
Programmer-RD-AIProgrammer-RD-AI
andcommitted
Update 02.ipynb.py
Co-Authored-By: Ranuga <[email protected]>
1 parent 3ecfdeb commit dddbcdb

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.virtual_documents/02.ipynb.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,25 @@ def forward(self,X):
9595
untrained_preds[0],y_test[0]
9696

9797

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+
98119

0 commit comments

Comments
 (0)