deepof_experiments.smk 5.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
# @authors lucasmiranda42
# encoding: utf-8
# deepof_experiments

"""

Snakefile for data and imputation.
Execution: sbatch snakemake
Plot DAG: snakemake --snakefile deepof_experiments.smk --forceall --dag | dot -Tpdf > deepof_experiments_DAG.pdf
Plot rule graph: snakemake --snakefile deepof_experiments.smk --forceall --rulegraph | dot -Tpdf > deepof_experiments_RULEGRAPH.pdf

"""

14
import os
15

lucas_miranda's avatar
lucas_miranda committed
16
outpath = "/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/logs/"
lucas_miranda's avatar
lucas_miranda committed
17
18
losses = ["ELBO" , "MMD", "ELBO+MMD"]
encodings = [2, 4, 6, 8, 10, 12, 14, 16]
19
20
cluster_numbers = [25]  # [1, 5, 10, 15, 20, 25]
latent_reg = ["none", "categorical", "variance", "categorical+variance"]
21
entropy_knn = [20, 50, 80, 100]
22
pheno_weights = [0.01, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 10.0, 100.0]
23

24

25
26
rule deepof_experiments:
    input:
lucas_miranda's avatar
lucas_miranda committed
27
        # "/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/supplementary_notebooks/recognise_elliptical_arena.ipynb",
28
29
30
31
32
33
34
35
36
        # expand(
        #     os.path.join(
        #         outpath,
        #         "coarse_hyperparameter_tuning/trained_weights/GMVAE_loss={loss}_k={k}_encoding={enc}_final_weights.h5",
        #     ),
        #     loss=losses,
        #     k=cluster_numbers,
        #     enc=encodings,
        # ),
lucas_miranda's avatar
lucas_miranda committed
37
38
39
40
41
42
43
44
45
        expand(
            "/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/logs/latent_regularization_experiments/trained_weights/"
            "GMVAE_loss={loss}_encoding={encs}_k={k}_latreg={latreg}_entropyknn={entknn}_final_weights.h5",
            loss=losses,
            encs=encodings,
            k=cluster_numbers,
            latreg=latent_reg,
            entknn=entropy_knn,
        ),
46
47
48
49
50
51
52
53
        # expand(
        #     "/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/logs/pheno_classification_experiments/trained_weights/"
        #     "GMVAE_loss={loss}_encoding={encs}_k={k}_pheno={phenos}_run_1_final_weights.h5",
        #     loss=losses,
        #     encs=encodings,
        #     k=cluster_numbers,
        #     phenos=pheno_weights,
        # ),
54
55


56
57
rule elliptical_arena_detector:
    input:
58
        to_exec="/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/supplementary_notebooks/recognise_elliptical_arena_blank.ipynb",
59
    output:
60
        exec="/psycl/g/mpsstatgen/lucas/DLC/DLC_autoencoders/DeepOF/deepof/supplementary_notebooks/recognise_elliptical_arena.ipynb",
61
    shell:
62
        "papermill {input.to_exec} "
63
        "-p vid_path './supplementary_notebooks/' "
64
        "-p log_path './logs/' "
65
        "-p out_path './deepof/trained_models/' "
66
67
68
        "{output.exec}"


69
rule coarse_hyperparameter_tuning:
70
    input:
71
        data_path="/psycl/g/mpsstatgen/lucas/DLC/DLC_models/deepof_single_topview/",
72
73
74
    output:
        trained_models=os.path.join(
            outpath,
75
            "coarse_hyperparameter_tuning/trained_weights/GMVAE_loss={loss}_k={k}_encoding={enc}_final_weights.h5",
76
77
78
79
        ),
    shell:
        "pipenv run python -m deepof.train_model "
        "--train-path {input.data_path} "
80
        "--val-num 25 "
81
        "--components {wildcards.k} "
82
83
84
85
86
87
        "--input-type coords "
        "--predictor 0 "
        "--phenotype-classifier 0 "
        "--variational True "
        "--loss {wildcards.loss} "
        "--kl-warmup 20 "
88
        "--mmd-warmup 0 "
89
        "--encoding-size {wildcards.enc} "
90
91
        "--batch-size 256 "
        "--window-size 24 "
92
        "--window-step 12 "
93
94
        "--output-path {outpath}coarse_hyperparameter_tuning "
        "--hyperparameter-tuning hyperband "
95
        "--hpt-trials 1"
96
97


98
99
rule latent_regularization_experiments:
    input:
100
101
102
        data_path=ancient(
            "/psycl/g/mpsstatgen/lucas/DLC/DLC_models/deepof_single_topview/"
        ),
103
104
105
    output:
        trained_models=os.path.join(
            outpath,
106
            "latent_regularization_experiments/trained_weights/GMVAE_loss={loss}_encoding={encs}_k={k}_latreg={latreg}_entropyknn={entknn}_final_weights.h5",
107
108
109
110
111
112
113
114
115
116
117
118
        ),
    shell:
        "pipenv run python -m deepof.train_model "
        "--train-path {input.data_path} "
        "--val-num 5 "
        "--components {wildcards.k} "
        "--input-type coords "
        "--predictor 0 "
        "--phenotype-classifier 0 "
        "--variational True "
        "--latent-reg {wildcards.latreg} "
        "--loss {wildcards.loss} "
119
120
        "--kl-warmup 5 "
        "--mmd-warmup 5 "
121
122
        "--montecarlo-kl 10 "
        "--encoding-size {wildcards.encs} "
123
        "--entropy-knn {wildcards.entknn} "
124
125
126
        "--batch-size 256 "
        "--window-size 24 "
        "--window-step 12 "
127

128
        "--output-path {outpath}latent_regularization_experiments"
129
        # "--exclude-bodyparts Tail_base,Tail_1,Tail_2,Tail_tip "
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158


rule explore_phenotype_classification:
    input:
        data_path="/psycl/g/mpsstatgen/lucas/DLC/DLC_models/deepof_single_topview/",
    output:
        trained_models=os.path.join(
            outpath,
            "pheno_classification_experiments/trained_weights/GMVAE_loss={loss}_encoding={encs}_k={k}_pheno={phenos}_run_1_final_weights.h5",
        ),
    shell:
        "pipenv run python -m deepof.train_model "
        "--train-path {input.data_path} "
        "--val-num 15 "
        "--components {wildcards.k} "
        "--input-type coords "
        "--predictor 0 "
        "--phenotype-classifier {wildcards.phenos} "
        "--variational True "
        "--loss {wildcards.loss} "
        "--kl-warmup 20 "
        "--mmd-warmup 20 "
        "--montecarlo-kl 10 "
        "--encoding-size {wildcards.encs} "
        "--batch-size 256 "
        "--window-size 11 "
        "--window-step 11 "
        "--stability-check 3  "
        "--output-path {outpath}pheno_classification_experiments"