Skip to content
Snippets Groups Projects
Commit 25d26f13 authored by Gonzalo Martin Garcia's avatar Gonzalo Martin Garcia
Browse files

add .ipynb_checkpoints to .gitignore

parent 393e6d27
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@
*/trained_ddpm
root
experiments
.ipynb_checkpoints
trainer/__pycache__
%% Cell type:code id: tags:
``` python
from trainer.train import *
from dataloader.load import *
from models.Framework import *
from models.unet_unconditional_diffusion import *
import torch
from torch import nn
```
%% Cell type:markdown id: tags:
# Prepare experiment
1. Adapt settings below (for data path, only use absolute paths!!)
2. run both cells of the notebook, this creates a folder containing the json setting files
2. put the folder on the HPC
3. the following command starts the training `python main.py train "<absolute path of folder in hpc>"` add it to the batch file
%% Cell type:code id: tags:
``` python
import torch
#path to store, path to load data , path to checkpoint
#basic settings:
learning_rate = 0.0001
batchsize = 8
datapath = "/work/lect0100/lhq_256"
checkpoint_path = None #when training from checkpoint
experimentname = "/Users/gonzalo/Desktop/testing/" + "test1" #always change experiment name!
epochs = 20
diffusion_steps = 25
image_size = 64
channels = 3
store_iter = 5
optimizername = "torch.optim.AdamW"
name_appendix = 'DM_bottleneck'# id for WANDB
#advanced settings: change directly in dictionary
meta_setting = dict(modelname = "UNet_Unconditional_Diffusion_Bottleneck_Variant",
dataset = "UnconditionalDataset",
framework = "DDPM",
trainloop_function = "ddpm_trainer",
batchsize = batchsize,
)
dataset_setting = dict(fpath = datapath,
img_size = image_size,
frac =0.8,
skip_first_n = 0,
ext = ".png",
transform=True
)
model_setting = dict( channels_in=channels,
channels_out =channels ,
activation='relu', # activation function. Options: {'relu', 'leakyrelu', 'selu', 'gelu', 'silu'/'swish'}
weight_init='he', # weight initialization. Options: {'he', 'torch'}
projection_features=64, # number of image features after first convolution layer
time_dim=batchsize, #dont chnage!!!
time_channels=diffusion_steps, # number of time channels #TODO same as diffusion steps?
num_stages=4, # number of stages in contracting/expansive path
stage_list=None, # specify number of features produced by stages
num_blocks=1, # number of ConvResBlock in each contracting/expansive path
num_groupnorm_groups=32, # number of groups used in Group Normalization inside a ConvResBlock
dropout=0.1, # drop-out to be applied inside a ConvResBlock
attention_list=None, # specify MHA pattern across stages
num_attention_heads=1,
)
framework_setting = dict(
diffusion_steps = diffusion_steps, # dont change!!
out_shape = (channels,image_size,image_size), # dont change!!
noise_schedule = 'linear',
beta_1 = 1e-4,
beta_T = 0.02,
alpha_bar_lower_bound = 0.9,
var_schedule = 'same',
kl_loss = 'simplified',
recon_loss = 'none',
)
training_setting = dict(
epochs = epochs,
store_iter = store_iter,
eval_iter = 3,
optimizer_class=optimizername,
optimizer_params=dict(lr=learning_rate), # don't change!
scheduler_class= None,
scheduler_params=None,
last_epoch=-1,
learning_rate = learning_rate,
lr_schedule = False,
verbose = True,
name_appendix=name_appendix,
checkpoint_path= checkpoint_path,
)
```
%% Cell type:code id: tags:
``` python
import os
import json
f = experimentname
if os.path.exists(f):
print("path already exists, pick a new name!")
print("break")
else:
print("create folder")
os.mkdir(f)
print("folder created ")
with open(f+"/meta_setting.json","w+") as fp:
json.dump(meta_setting,fp)
with open(f+"/dataset_setting.json","w+") as fp:
json.dump(dataset_setting,fp)
with open(f+"/model_setting.json","w+") as fp:
json.dump(model_setting,fp)
with open(f+"/framework_setting.json","w+") as fp:
json.dump(framework_setting,fp)
with open(f+"/training_setting.json","w+") as fp:
json.dump(training_setting,fp)
print("stored json files in folder")
print(meta_setting)
print(dataset_setting)
print(model_setting)
print(framework_setting)
print(training_setting)
```
%% Output
path already exists, pick a new name!
break
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment