-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from BerndDoser/mises-fisher
BCEWithLogitsLoss for reconstruction loss
- Loading branch information
Showing
20 changed files
with
457 additions
and
69 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,6 +1,6 @@ | ||
__pycache__ | ||
*.ckpt | ||
HiPSter | ||
lightning_logs | ||
HiPSter/ | ||
lightning_logs/ | ||
data/MNIST/ | ||
wandb | ||
wandb/ |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import lightning.pytorch as pl | ||
import yaml | ||
|
||
import data | ||
import models | ||
|
||
if __name__ == "__main__": | ||
|
||
with open("experiments/illustris-svae.yaml", "r", encoding="utf-8") as stream: | ||
config = yaml.load(stream, Loader=yaml.Loader) | ||
|
||
model = models.RotationalSphericalVariationalAutoencoder(**(config["model"]["init_args"])) | ||
|
||
data_module = data.IllustrisSdssDataModule( | ||
data_directories=["/home/doserbd/data/machine-learning/SKIRT_synthetic_images/TNG50/sdss/snapnum_095/data/"], | ||
num_workers=8, batch_size=32) | ||
|
||
trainer = pl.Trainer(accelerator='gpu', max_epochs=-1) | ||
trainer.fit(model, data_module) | ||
|
||
print("Done.") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import argparse | ||
|
||
import torch | ||
import yaml | ||
|
||
import data | ||
import models | ||
|
||
if __name__ == "__main__": | ||
|
||
parser = argparse.ArgumentParser(description="Test SVAE") | ||
parser.add_argument("--config", "-c", default="config.yaml", | ||
help="config file (default = 'config.yaml').") | ||
|
||
vars = vars(parser.parse_args()) | ||
if "config" in vars: | ||
with open(vars["config"], "r", encoding="utf-8") as stream: | ||
config = yaml.load(stream, Loader=yaml.Loader) | ||
|
||
model = models.RotationalSphericalVariationalAutoencoder(**(config["model"]["init_args"])) | ||
|
||
checkpoint = torch.load("lightning_logs/version_13/checkpoints/epoch=43-step=3344.ckpt") | ||
model.load_state_dict(checkpoint["state_dict"]) | ||
|
||
data_module = data.IllustrisSdssDataModule(**(config["data"]["init_args"])) | ||
data_module.setup("predict") | ||
dataloader = data_module.predict_dataloader() | ||
|
||
for batch in dataloader: | ||
image = batch["image"] | ||
z_mean, _ = model.encode(image) | ||
print(z_mean) | ||
break |
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,39 @@ | ||
seed_everything: 42 | ||
|
||
model: | ||
class_path: models.RotationalSphericalVariationalAutoencoder | ||
init_args: | ||
h_dim: 256 | ||
z_dim: 3 | ||
distribution: "vmf" | ||
|
||
data: | ||
class_path: data.GalaxyZooDataModule | ||
init_args: | ||
data_dir: /hits/basement/ain/Data/KaggleGalaxyZoo/images_training_rev1 | ||
extension: jpg | ||
batch_size: 256 | ||
shuffle: True | ||
num_workers: 12 | ||
|
||
optimizer: | ||
class_path: torch.optim.Adam | ||
init_args: | ||
lr: 0.001 | ||
|
||
lr_scheduler: | ||
class_path: lightning.pytorch.cli.ReduceLROnPlateau | ||
init_args: | ||
mode: min | ||
factor: 0.1 | ||
patience: 500 | ||
cooldown: 500 | ||
min_lr: 1.e-5 | ||
monitor: train_loss | ||
verbose: True | ||
|
||
trainer: | ||
max_epochs: -1 | ||
accelerator: gpu | ||
devices: 1 | ||
precision: 32 |
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,46 @@ | ||
seed_everything: 42 | ||
|
||
model: | ||
class_path: models.RotationalSphericalVariationalAutoencoder | ||
init_args: | ||
h_dim: 256 | ||
z_dim: 3 | ||
distribution: "vmf" | ||
|
||
data: | ||
class_path: data.IllustrisSdssDataModule | ||
init_args: | ||
data_directories: ["/home/doserbd/data/machine-learning/SKIRT_synthetic_images/TNG50/sdss/snapnum_095/data/"] | ||
extension: fits | ||
minsize: 100 | ||
batch_size: 32 | ||
shuffle: True | ||
num_workers: 8 | ||
|
||
optimizer: | ||
class_path: torch.optim.Adam | ||
init_args: | ||
lr: 0.001 | ||
|
||
lr_scheduler: | ||
class_path: lightning.pytorch.cli.ReduceLROnPlateau | ||
init_args: | ||
mode: min | ||
factor: 0.1 | ||
patience: 500 | ||
cooldown: 500 | ||
min_lr: 1.e-5 | ||
monitor: train_loss | ||
verbose: True | ||
|
||
trainer: | ||
max_epochs: -1 | ||
accelerator: gpu | ||
devices: 1 | ||
precision: 32 | ||
logger: | ||
class_path: lightning.pytorch.loggers.WandbLogger | ||
init_args: | ||
project: spherinator | ||
name: illustris-svae-bce | ||
log_model: True |
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,42 @@ | ||
seed_everything: 42 | ||
|
||
model: | ||
class_path: models.RotationalSphericalAutoencoder | ||
|
||
data: | ||
class_path: data.IllustrisSdssDataModule | ||
init_args: | ||
data_directories: ["/home/doserbd/data/machine-learning/SKIRT_synthetic_images/TNG50/sdss/snapnum_095/data/"] | ||
extension: fits | ||
minsize: 100 | ||
batch_size: 32 | ||
shuffle: True | ||
num_workers: 8 | ||
|
||
optimizer: | ||
class_path: torch.optim.Adam | ||
init_args: | ||
lr: 0.001 | ||
|
||
lr_scheduler: | ||
class_path: lightning.pytorch.cli.ReduceLROnPlateau | ||
init_args: | ||
mode: min | ||
factor: 0.1 | ||
patience: 500 | ||
cooldown: 500 | ||
min_lr: 1.e-5 | ||
monitor: train_loss | ||
verbose: True | ||
|
||
trainer: | ||
max_epochs: -1 | ||
accelerator: gpu | ||
devices: 1 | ||
precision: 32 | ||
logger: | ||
class_path: lightning.pytorch.loggers.WandbLogger | ||
init_args: | ||
project: spherinator | ||
name: illustris-test | ||
log_model: True |
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.