Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reset+ema for vq-vae #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": false
}
]
}
13 changes: 7 additions & 6 deletions configs/vq_vae.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
model_params:
name: 'VQVAE'
name: "VQVAE"
in_channels: 3
quantizer: "ema_reset"
embedding_dim: 64
num_embeddings: 512
img_size: 64
beta: 0.25
beta: 1.0
mu: 0.99

data_params:
data_path: "Data/"
train_batch_size: 64
val_batch_size: 64
val_batch_size: 64
patch_size: 64
num_workers: 4


exp_params:
LR: 0.005
LR: 0.0003
weight_decay: 0.0
scheduler_gamma: 0.0
kld_weight: 0.00025
Expand All @@ -27,4 +28,4 @@ trainer_params:

logging_params:
save_dir: "logs/"
name: 'VQVAE'
name: "VQVAE"
7 changes: 6 additions & 1 deletion experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ def sample_images(self):
test_input, test_label = next(iter(self.trainer.datamodule.test_dataloader()))
test_input = test_input.to(self.curr_device)
test_label = test_label.to(self.curr_device)

vutils.save_image(test_input.data,
os.path.join(self.logger.log_dir ,
"Origin",
f"origin_{self.logger.name}_Epoch_{self.current_epoch}.png"),
normalize=True,
nrow=12)
# test_input, test_label = batch
recons = self.model.generate(test_input, labels = test_label)
vutils.save_image(recons.data,
Expand Down
1 change: 1 addition & 0 deletions models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .vq_vae import *
from .betatc_vae import *
from .dip_vae import *
from .quantizer import *


# Aliases
Expand Down
Loading