summaryrefslogtreecommitdiff
path: root/text_recognizer/models/vqvae.py
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-10 18:07:40 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-10-10 18:07:40 +0200
commit793f1ee1a653dd6a4eb47dab357aa5c0e2a9eb72 (patch)
tree6b64398a7ab55a4e3d1acccfed46c25d9bd80ea7 /text_recognizer/models/vqvae.py
parentef5e7e6a62a6d7223fe5a5137e2bfacba9ec12b6 (diff)
Refactor of vq models
Diffstat (limited to 'text_recognizer/models/vqvae.py')
-rw-r--r--text_recognizer/models/vqvae.py10
1 files changed, 0 insertions, 10 deletions
diff --git a/text_recognizer/models/vqvae.py b/text_recognizer/models/vqvae.py
index 92f28ad..4898852 100644
--- a/text_recognizer/models/vqvae.py
+++ b/text_recognizer/models/vqvae.py
@@ -20,12 +20,9 @@ class VQVAELitModel(BaseLitModel):
def training_step(self, batch: Tuple[Tensor, Tensor], batch_idx: int) -> Tensor:
"""Training step."""
data, _ = batch
-
reconstructions, commitment_loss = self(data)
-
loss = self.loss_fn(reconstructions, data)
loss = loss + self.commitment * commitment_loss
-
self.log("train/commitment_loss", commitment_loss)
self.log("train/loss", loss)
return loss
@@ -33,23 +30,16 @@ class VQVAELitModel(BaseLitModel):
def validation_step(self, batch: Tuple[Tensor, Tensor], batch_idx: int) -> None:
"""Validation step."""
data, _ = batch
-
reconstructions, commitment_loss = self(data)
-
loss = self.loss_fn(reconstructions, data)
- loss = loss + self.commitment * commitment_loss
-
self.log("val/commitment_loss", commitment_loss)
self.log("val/loss", loss, prog_bar=True)
def test_step(self, batch: Tuple[Tensor, Tensor], batch_idx: int) -> None:
"""Test step."""
data, _ = batch
-
reconstructions, commitment_loss = self(data)
-
loss = self.loss_fn(reconstructions, data)
loss = loss + self.commitment * commitment_loss
-
self.log("test/commitment_loss", commitment_loss)
self.log("test/loss", loss)