-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tensorboard logger * Minor * Update affine coupling * Fix flow block Add autoflake * Minor fixes * Add tests for trainer
- Loading branch information
1 parent
fc55341
commit d28101a
Showing
27 changed files
with
500 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
todo.py | ||
./runs | ||
./samples | ||
./.misc/notebooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- Norm flows can't can't work with discrete random variables, so we need to dequantize input image tensors. | ||
Here the simplest solution [implemented](../src/modules/utils/tensors.py): adding a small amount of noise to each discrete value. | ||
But in general it is better to use <a href="https://arxiv.org/abs/1902.00275">variational dequantization</a>. | ||
- Read more about <a href="https://arxiv.org/abs/1605.08803v3">KL duality</a> | ||
- Jacobian can be interpreted as an indicator of how the volume of the probability space changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from modules.logger.logger import TensorboardLogger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
|
||
from torch import Tensor | ||
from torch.utils.tensorboard import SummaryWriter | ||
|
||
|
||
class TensorboardLogger: | ||
def __init__(self, log_dir: str, run_name: str, log_steps: int): | ||
log_dir = os.path.join(log_dir, run_name) | ||
|
||
if not os.path.exists(log_dir): | ||
os.makedirs(log_dir) | ||
|
||
self.log_dir = log_dir | ||
self.log_steps = log_steps | ||
self.writer = SummaryWriter(log_dir=log_dir) | ||
|
||
def __del__(self): | ||
self.writer.flush() | ||
self.writer.close() | ||
|
||
def log_train_loss(self, loss: float, step: int): | ||
if step % self.log_steps == 0: | ||
self.writer.add_scalar("Loss/train", loss, step) | ||
|
||
def log_test_loss(self, loss: float, epoch: int): | ||
self.writer.add_scalar("Loss/test", loss, epoch) | ||
|
||
def log_images(self, grid: Tensor, step: int): | ||
self.writer.add_image(tag="samples", img_tensor=grid, global_step=step) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
"fixtures.blocks", | ||
"fixtures.config", | ||
"fixtures.inputs", | ||
"fixtures.trainer", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.