Skip to content

Commit

Permalink
Format code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
jameschapman19 authored and github-actions[bot] committed Sep 21, 2023
1 parent aab530c commit ce2f082
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cca_zoo/deep/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,33 @@ def training_step(self, batch: Dict[str, Any], batch_idx: int) -> torch.Tensor:
loss = self.loss(batch["views"])
for k, v in loss.items():
# Use f-string instead of concatenation
self.log(f"train/{k}", v, prog_bar=True, on_epoch=True, batch_size=batch["views"][0].shape[0])
self.log(
f"train/{k}",
v,
prog_bar=True,
on_epoch=True,
batch_size=batch["views"][0].shape[0],
)
return loss["objective"]

def validation_step(self, batch: Dict[str, Any], batch_idx: int) -> torch.Tensor:
"""Performs one step of validation on a batch of views."""
loss = self.loss(batch["views"])
for k, v in loss.items():
# Use f-string instead of concatenation
self.log(f"val/{k}", v, on_epoch=True, batch_size=batch["views"][0].shape[0])
self.log(
f"val/{k}", v, on_epoch=True, batch_size=batch["views"][0].shape[0]
)
return loss["objective"]

def test_step(self, batch: Dict[str, Any], batch_idx: int) -> torch.Tensor:
"""Performs one step of testing on a batch of views."""
loss = self.loss(batch["views"])
for k, v in loss.items():
# Use f-string instead of concatenation
self.log(f"test/{k}", v, on_epoch=True, batch_size=batch["views"][0].shape[0])
self.log(
f"test/{k}", v, on_epoch=True, batch_size=batch["views"][0].shape[0]
)
return loss["objective"]

@torch.no_grad()
Expand Down

0 comments on commit ce2f082

Please sign in to comment.