@@ -225,7 +225,7 @@ def forward(self, x):
225
225
# 2. Classifier (returns logits):
226
226
x = self .fc (x )
227
227
228
- return torch . sigmoid ( x )
228
+ return x
229
229
230
230
def loss (self , logits , labels ):
231
231
return self .loss_func (input = logits , target = labels )
@@ -234,27 +234,29 @@ def training_step(self, batch, batch_idx):
234
234
# 1. Forward pass:
235
235
x , y = batch
236
236
y_logits = self .forward (x )
237
+ y_scores = torch .sigmoid (y_logits )
237
238
y_true = y .view ((- 1 , 1 )).type_as (x )
238
239
239
240
# 2. Compute loss
240
241
train_loss = self .loss (y_logits , y_true )
241
242
242
243
# 3. Compute accuracy:
243
- self .log ("train_acc" , self .train_acc (y_logits , y_true .int ()), prog_bar = True )
244
+ self .log ("train_acc" , self .train_acc (y_scores , y_true .int ()), prog_bar = True )
244
245
245
246
return train_loss
246
247
247
248
def validation_step (self , batch , batch_idx ):
248
249
# 1. Forward pass:
249
250
x , y = batch
250
251
y_logits = self .forward (x )
252
+ y_scores = torch .sigmoid (y_logits )
251
253
y_true = y .view ((- 1 , 1 )).type_as (x )
252
254
253
255
# 2. Compute loss
254
256
self .log ("val_loss" , self .loss (y_logits , y_true ), prog_bar = True )
255
257
256
258
# 3. Compute accuracy:
257
- self .log ("val_acc" , self .valid_acc (y_logits , y_true .int ()), prog_bar = True )
259
+ self .log ("val_acc" , self .valid_acc (y_scores , y_true .int ()), prog_bar = True )
258
260
259
261
def configure_optimizers (self ):
260
262
parameters = list (self .parameters ())
0 commit comments