Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Unconditional Diffusion
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Diffusion Project
Unconditional Diffusion
Commits
3597a501
Commit
3597a501
authored
Jun 8, 2023
by
Tobias Seibel
Browse files
Options
Downloads
Patches
Plain Diff
path to data fixed
parent
7ba3be86
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiment_creator.ipynb
+1
-1
1 addition, 1 deletion
experiment_creator.ipynb
with
1 addition
and
1 deletion
experiment_creator.ipynb
+
1
−
1
View file @
3597a501
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
"#basic settings:\n",
"#basic settings:\n",
"learning_rate = 0.0001\n",
"learning_rate = 0.0001\n",
"batchsize = 128\n",
"batchsize = 128\n",
"datapath = \"work/lect0100/lhq256\"\n",
"datapath = \"work/lect0100/lhq
_
256\"\n",
"checkpoint_path = None #when training from checkpoint\n",
"checkpoint_path = None #when training from checkpoint\n",
"experimentname = \"/work/lect0100/results/\" + \"test1\" #always change experiment name! \n",
"experimentname = \"/work/lect0100/results/\" + \"test1\" #always change experiment name! \n",
"epochs = 20\n",
"epochs = 20\n",
...
...
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
trainer.train
import
*
from
trainer.train
import
*
from
dataloader.load
import
*
from
dataloader.load
import
*
from
models.Framework
import
*
from
models.Framework
import
*
from
models.unet_unconditional_diffusion
import
*
from
models.unet_unconditional_diffusion
import
*
import
torch
import
torch
from
torch
import
nn
from
torch
import
nn
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Prepare experiment
# Prepare experiment
1.
Adapt settings below (for data path, only use absolute paths!!)
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.
run both cells of the notebook, this creates a folder containing the json setting files
2.
put the folder on the HPC
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
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:
%% Cell type:code id: tags:
```
python
```
python
import
torch
import
torch
#path to store, path to load data , path to checkpoint
#path to store, path to load data , path to checkpoint
#basic settings:
#basic settings:
learning_rate
=
0.0001
learning_rate
=
0.0001
batchsize
=
128
batchsize
=
128
datapath
=
"
work/lect0100/lhq256
"
datapath
=
"
work/lect0100/lhq
_
256
"
checkpoint_path
=
None
#when training from checkpoint
checkpoint_path
=
None
#when training from checkpoint
experimentname
=
"
/work/lect0100/results/
"
+
"
test1
"
#always change experiment name!
experimentname
=
"
/work/lect0100/results/
"
+
"
test1
"
#always change experiment name!
epochs
=
20
epochs
=
20
diffusion_steps
=
500
diffusion_steps
=
500
image_size
=
64
image_size
=
64
channels
=
3
channels
=
3
store_iter
=
5
store_iter
=
5
optimizername
=
"
torch.optim.AdamW
"
optimizername
=
"
torch.optim.AdamW
"
name_appendix
=
'
DM_testing_0
'
# id for WANDB
name_appendix
=
'
DM_testing_0
'
# id for WANDB
#advanced settings: change directly in dictionary
#advanced settings: change directly in dictionary
meta_setting
=
dict
(
modelname
=
"
UNet_Unconditional_Diffusion
"
,
meta_setting
=
dict
(
modelname
=
"
UNet_Unconditional_Diffusion
"
,
dataset
=
"
UnconditionalDataset
"
,
dataset
=
"
UnconditionalDataset
"
,
framework
=
"
DDPM
"
,
framework
=
"
DDPM
"
,
trainloop_function
=
"
ddpm_trainer
"
,
trainloop_function
=
"
ddpm_trainer
"
,
batchsize
=
batchsize
,
batchsize
=
batchsize
,
)
)
dataset_setting
=
dict
(
fpath
=
datapath
,
dataset_setting
=
dict
(
fpath
=
datapath
,
img_size
=
image_size
,
img_size
=
image_size
,
frac
=
0.8
,
frac
=
0.8
,
skip_first_n
=
0
,
skip_first_n
=
0
,
ext
=
"
.png
"
,
ext
=
"
.png
"
,
transform
=
True
transform
=
True
)
)
model_setting
=
dict
(
channels_in
=
channels
,
model_setting
=
dict
(
channels_in
=
channels
,
channels_out
=
channels
,
channels_out
=
channels
,
activation
=
'
relu
'
,
# activation function. Options: {'relu', 'leakyrelu', 'selu', 'gelu', 'silu'/'swish'}
activation
=
'
relu
'
,
# activation function. Options: {'relu', 'leakyrelu', 'selu', 'gelu', 'silu'/'swish'}
weight_init
=
'
he
'
,
# weight initialization. Options: {'he', 'torch'}
weight_init
=
'
he
'
,
# weight initialization. Options: {'he', 'torch'}
projection_features
=
64
,
# number of image features after first convolution layer
projection_features
=
64
,
# number of image features after first convolution layer
time_dim
=
batchsize
,
#dont chnage!!!
time_dim
=
batchsize
,
#dont chnage!!!
time_channels
=
diffusion_steps
,
# number of time channels #TODO same as diffusion steps?
time_channels
=
diffusion_steps
,
# number of time channels #TODO same as diffusion steps?
num_stages
=
4
,
# number of stages in contracting/expansive path
num_stages
=
4
,
# number of stages in contracting/expansive path
stage_list
=
None
,
# specify number of features produced by stages
stage_list
=
None
,
# specify number of features produced by stages
num_blocks
=
2
,
# number of ConvResBlock in each contracting/expansive path
num_blocks
=
2
,
# number of ConvResBlock in each contracting/expansive path
num_groupnorm_groups
=
32
,
# number of groups used in Group Normalization inside a ConvResBlock
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
dropout
=
0.1
,
# drop-out to be applied inside a ConvResBlock
attention_list
=
None
,
# specify MHA pattern across stages
attention_list
=
None
,
# specify MHA pattern across stages
num_attention_heads
=
1
,
num_attention_heads
=
1
,
)
)
framework_setting
=
dict
(
framework_setting
=
dict
(
diffusion_steps
=
diffusion_steps
,
# dont change!!
diffusion_steps
=
diffusion_steps
,
# dont change!!
out_shape
=
(
channels
,
image_size
,
image_size
),
# dont change!!
out_shape
=
(
channels
,
image_size
,
image_size
),
# dont change!!
noise_schedule
=
'
linear
'
,
noise_schedule
=
'
linear
'
,
beta_1
=
1e-4
,
beta_1
=
1e-4
,
beta_T
=
0.02
,
beta_T
=
0.02
,
alpha_bar_lower_bound
=
0.9
,
alpha_bar_lower_bound
=
0.9
,
var_schedule
=
'
same
'
,
var_schedule
=
'
same
'
,
kl_loss
=
'
simplified
'
,
kl_loss
=
'
simplified
'
,
recon_loss
=
'
none
'
,
recon_loss
=
'
none
'
,
)
)
training_setting
=
dict
(
training_setting
=
dict
(
epochs
=
epochs
,
epochs
=
epochs
,
store_iter
=
store_iter
,
store_iter
=
store_iter
,
eval_iter
=
3
,
eval_iter
=
3
,
optimizer_class
=
optimizername
,
optimizer_class
=
optimizername
,
optimizer_params
=
dict
(
lr
=
learning_rate
),
# don't change!
optimizer_params
=
dict
(
lr
=
learning_rate
),
# don't change!
scheduler_class
=
None
,
scheduler_class
=
None
,
scheduler_params
=
None
,
scheduler_params
=
None
,
last_epoch
=-
1
,
last_epoch
=-
1
,
learning_rate
=
learning_rate
,
learning_rate
=
learning_rate
,
lr_schedule
=
False
,
lr_schedule
=
False
,
verbose
=
True
,
verbose
=
True
,
name_appendix
=
name_appendix
,
name_appendix
=
name_appendix
,
checkpoint_path
=
checkpoint_path
,
checkpoint_path
=
checkpoint_path
,
)
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
os
import
os
import
json
import
json
f
=
experimentname
f
=
experimentname
if
os
.
path
.
exists
(
f
):
if
os
.
path
.
exists
(
f
):
print
(
"
path already exists, pick a new name!
"
)
print
(
"
path already exists, pick a new name!
"
)
print
(
"
break
"
)
print
(
"
break
"
)
else
:
else
:
print
(
"
create folder
"
)
print
(
"
create folder
"
)
os
.
mkdir
(
f
)
os
.
mkdir
(
f
)
print
(
"
folder created
"
)
print
(
"
folder created
"
)
with
open
(
f
+
"
/meta_setting.json
"
,
"
w+
"
)
as
fp
:
with
open
(
f
+
"
/meta_setting.json
"
,
"
w+
"
)
as
fp
:
json
.
dump
(
meta_setting
,
fp
)
json
.
dump
(
meta_setting
,
fp
)
with
open
(
f
+
"
/dataset_setting.json
"
,
"
w+
"
)
as
fp
:
with
open
(
f
+
"
/dataset_setting.json
"
,
"
w+
"
)
as
fp
:
json
.
dump
(
dataset_setting
,
fp
)
json
.
dump
(
dataset_setting
,
fp
)
with
open
(
f
+
"
/model_setting.json
"
,
"
w+
"
)
as
fp
:
with
open
(
f
+
"
/model_setting.json
"
,
"
w+
"
)
as
fp
:
json
.
dump
(
model_setting
,
fp
)
json
.
dump
(
model_setting
,
fp
)
with
open
(
f
+
"
/framework_setting.json
"
,
"
w+
"
)
as
fp
:
with
open
(
f
+
"
/framework_setting.json
"
,
"
w+
"
)
as
fp
:
json
.
dump
(
framework_setting
,
fp
)
json
.
dump
(
framework_setting
,
fp
)
with
open
(
f
+
"
/training_setting.json
"
,
"
w+
"
)
as
fp
:
with
open
(
f
+
"
/training_setting.json
"
,
"
w+
"
)
as
fp
:
json
.
dump
(
training_setting
,
fp
)
json
.
dump
(
training_setting
,
fp
)
print
(
"
stored json files in folder
"
)
print
(
"
stored json files in folder
"
)
print
(
meta_setting
)
print
(
meta_setting
)
print
(
dataset_setting
)
print
(
dataset_setting
)
print
(
model_setting
)
print
(
model_setting
)
print
(
framework_setting
)
print
(
framework_setting
)
print
(
training_setting
)
print
(
training_setting
)
```
```
%% Output
%% Output
path already exists, pick a new name!
path already exists, pick a new name!
break
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment