diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-10-10 18:07:40 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-10-10 18:07:40 +0200 |
commit | 793f1ee1a653dd6a4eb47dab357aa5c0e2a9eb72 (patch) | |
tree | 6b64398a7ab55a4e3d1acccfed46c25d9bd80ea7 | |
parent | ef5e7e6a62a6d7223fe5a5137e2bfacba9ec12b6 (diff) |
Refactor of vq models
-rw-r--r-- | text_recognizer/models/vqgan.py | 1 | ||||
-rw-r--r-- | text_recognizer/models/vqvae.py | 10 |
2 files changed, 0 insertions, 11 deletions
diff --git a/text_recognizer/models/vqgan.py b/text_recognizer/models/vqgan.py index 30b46a7..6e4d3fb 100644 --- a/text_recognizer/models/vqgan.py +++ b/text_recognizer/models/vqgan.py @@ -24,7 +24,6 @@ class VQGANLitModel(BaseLitModel): ) -> Tensor: """Training step.""" data, _ = batch - reconstructions, commitment_loss = self(data) if optimizer_idx == 0: 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) |