Skip to content

Commit

Permalink
change syntaxis
Browse files Browse the repository at this point in the history
  • Loading branch information
namsaraeva committed May 29, 2024
1 parent e57b342 commit 00c5590
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sparcscore/ml/plmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ def training_step(self, batch):
target = target.unsqueeze(1)
output = self.network(data) # Forward pass, only one output

loss = self.configure_loss()
loss_func = self.configure_loss()

if self.hparams["loss"] == "huber": # Huber loss
loss = loss(output, target, delta=self.hparams["huber_delta"], reduction='mean')
loss = loss_func(output, target, delta=self.hparams["huber_delta"], reduction='mean')
else: # MSE
loss = loss(output, target)
loss = loss_func(output, target)

self.log('loss/train', loss, on_step=False, on_epoch=True, prog_bar=True)
self.log('mse/train', self.mse(output, target), on_epoch=True, prog_bar=True)
Expand All @@ -237,12 +237,12 @@ def validation_step(self, batch):
target = target.unsqueeze(1)
output = self.network(data)

loss = self.configure_loss()
loss_func = self.configure_loss()

if self.hparams["loss"] == "huber": # Huber loss
loss = loss(output, target, delta=self.hparams["huber_delta"], reduction='mean')
loss = loss_func(output, target, delta=self.hparams["huber_delta"], reduction='mean')
else: # MSE
loss = loss(output, target)
loss = loss_func(output, target)

self.log('loss/val', loss, on_step=False, on_epoch=True, prog_bar=True)
self.log('mse/val', self.mse(output, target), on_epoch=True, prog_bar=True)
Expand All @@ -255,12 +255,12 @@ def test_step(self, batch):
target = target.unsqueeze(1)
output = self.network(data)

loss = self.configure_loss()
loss_func = self.configure_loss()

if self.hparams["loss"] == "huber": # Huber loss
loss = loss(output, target, delta=self.hparams["huber_delta"], reduction='mean')
loss = loss_func(output, target, delta=self.hparams["huber_delta"], reduction='mean')
else: # MSE
loss = loss(output, target)
loss = loss_func(output, target)

self.log('loss/test', loss, on_step=False, on_epoch=True, prog_bar=True)
self.log('mse/test', self.mse(output, target), on_epoch=True, prog_bar=True)
Expand Down

0 comments on commit 00c5590

Please sign in to comment.