forked from pinellolab/DNA-Diffusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
58 lines (49 loc) · 1.5 KB
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from accelerate import Accelerator, DistributedDataParallelKwargs
from dnadiffusion.data.dataloader import load_data
from dnadiffusion.models.diffusion import Diffusion
from dnadiffusion.models.unet import UNet
from dnadiffusion.utils.train_util import TrainLoop
def train():
kwargs = DistributedDataParallelKwargs(find_unused_parameters=True)
accelerator = Accelerator(
kwargs_handlers=[kwargs],
split_batches=True,
log_with=["wandb"],
)
data = load_data(
data_path="src/dnadiffusion/data/K562_hESCT0_HepG2_GM12878_12k_sequences_per_group.txt",
saved_data_path="src/dnadiffusion/data/encode_data.pkl",
subset_list=[
"GM12878_ENCLB441ZZZ",
"hESCT0_ENCLB449ZZZ",
"K562_ENCLB843GMH",
"HepG2_ENCLB029COU",
],
limit_total_sequences=0,
num_sampling_to_compare_cells=1000,
load_saved_data=True,
)
unet = UNet(
dim=200,
channels=1,
dim_mults=(1, 2, 4),
resnet_block_groups=4,
)
diffusion = Diffusion(
unet,
timesteps=50,
)
TrainLoop(
data=data,
model=diffusion,
accelerator=accelerator,
epochs=10000,
loss_show_epoch=10,
sample_epoch=100,
save_epoch=500,
model_name="model_48k_sequences_per_group_K562_hESCT0_HepG2_GM12878_12k",
image_size=200,
num_sampling_to_compare_cells=1000,
).train_loop()
if __name__ == "__main__":
train()