From 61741a116198cb7a5551420c391c7b9be6e75373 Mon Sep 17 00:00:00 2001 From: Florian Muller-Fouarge Date: Wed, 3 Mar 2021 17:02:39 +0100 Subject: [PATCH 1/3] Correct num_rows calculation in LatentDimInterpolator callback --- pl_bolts/callbacks/variational.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pl_bolts/callbacks/variational.py b/pl_bolts/callbacks/variational.py index 4d5f4c6e23..189b00f800 100644 --- a/pl_bolts/callbacks/variational.py +++ b/pl_bolts/callbacks/variational.py @@ -67,8 +67,7 @@ def on_epoch_end(self, trainer: Trainer, pl_module: LightningModule) -> None: ) images = torch.cat(images, dim=0) # type: ignore[assignment] - num_images = (self.range_end - self.range_start)**2 - num_rows = int(math.sqrt(num_images)) + num_rows = int(math.sqrt(self.steps)) grid = torchvision.utils.make_grid(images, nrow=num_rows, normalize=self.normalize) str_title = f'{pl_module.__class__.__name__}_latent_space' trainer.logger.experiment.add_image(str_title, grid, global_step=trainer.global_step) From 2c50019688e42341644a4cb2e46489328a26f98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCller-Fouarge?= <57919375+FlorianMF@users.noreply.github.com> Date: Wed, 3 Mar 2021 16:11:30 +0000 Subject: [PATCH 2/3] Update variational.py --- pl_bolts/callbacks/variational.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pl_bolts/callbacks/variational.py b/pl_bolts/callbacks/variational.py index 189b00f800..a6d7f7f04e 100644 --- a/pl_bolts/callbacks/variational.py +++ b/pl_bolts/callbacks/variational.py @@ -67,7 +67,7 @@ def on_epoch_end(self, trainer: Trainer, pl_module: LightningModule) -> None: ) images = torch.cat(images, dim=0) # type: ignore[assignment] - num_rows = int(math.sqrt(self.steps)) + num_rows = self.steps grid = torchvision.utils.make_grid(images, nrow=num_rows, normalize=self.normalize) str_title = f'{pl_module.__class__.__name__}_latent_space' trainer.logger.experiment.add_image(str_title, grid, global_step=trainer.global_step) From c0694d7bcbc9c9dd51fc27ab03db3eacb4c5501d Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Tue, 9 Mar 2021 11:38:01 +0100 Subject: [PATCH 3/3] format --- pl_bolts/callbacks/variational.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pl_bolts/callbacks/variational.py b/pl_bolts/callbacks/variational.py index a6d7f7f04e..68ffb70868 100644 --- a/pl_bolts/callbacks/variational.py +++ b/pl_bolts/callbacks/variational.py @@ -1,4 +1,3 @@ -import math from typing import List import numpy as np