From 793f1ee1a653dd6a4eb47dab357aa5c0e2a9eb72 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 10 Oct 2021 18:07:40 +0200 Subject: Refactor of vq models --- text_recognizer/models/vqgan.py | 1 - text_recognizer/models/vqvae.py | 10 ---------- 2 files changed, 11 deletions(-) (limited to 'text_recognizer/models') 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) -- cgit v1.2.3-70-g09d2