# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# cd PycharmProjects/master_thesis/ && conda activate torch && export TORCH_HOME=/home/lucky/datasets

# +
nas_list = ['DARTS-V1', 'DARTS-V2', 'ENAS', 'GDAS']
#sampling_list = ['rs', 'ccrs']
#sampling_list = ['cc_outlier_removal']
sampling_list = ['aeeasy', 'tleasy']
fractions = ['0.75', '0.50', '0.25']

commands = []
for n, nas_approach in enumerate(nas_list):
    #command = "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh cifar100 1 -1 baseline 1.0"
    command = ""
    for sampling_element in sampling_list:
        for fraction in fractions:
            if command != "":
                command += " && "
            command += "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh cifar100 1 -1 "
            command += sampling_element + " " + fraction
    commands.append(command)
commands

# +
nas_list = ['DARTS-V1', 'DARTS-V2', 'ENAS', 'GDAS']
#sampling_list = ['rs', 'ccrs']
#sampling_list = ['cc_outlier_removal']
sampling_list = ['aeeasy', 'tleasy']
fractions = ['0.75', '0.50', '0.25']

commands = []
for n, nas_approach in enumerate(nas_list):
    #command = "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh cifar100 1 -1 baseline 1.0"
    command = ""
    for sampling_element in sampling_list:
        for fraction in fractions:
            if command != "":
                command += " && "
            command += "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh ImageNet16-120 1 -1 "
            command += sampling_element + " " + fraction
    commands.append(command)
commands

# +
nas_list = ['DARTS-V1', 'DARTS-V2', 'ENAS', 'GDAS']
#sampling_list = ['rs', 'ccrs']
#sampling_list = ['cc_outlier_removal']
sampling_list = ['aeeasy', 'tleasy']
fractions = ['0.75', '0.50', '0.25']

commands = []
for n, nas_approach in enumerate(nas_list):
    #command = "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh cifar100 1 -1 baseline 1.0"
    command = ""
    for sampling_element in sampling_list:
        for fraction in fractions:
            if command != "":
                command += " && "
            command += "CUDA_VISIBLE_DEVICES=" + str(n) + " bash ./scripts-search/algos/" + nas_approach + ".sh cifar100 1 -1 "
            command += sampling_element + " " + fraction
    commands.append(command)
commands

# +
channels = [16, 32, 64]

def train_a_net_command(network, cuda_device=-1, server=False):
    command = ""
    for channel in channels:
        if command != "":
            command += " && "
        if cuda_device != -1:
            command += "CUDA_VISIBLE_DEVICES=" + str(cuda_device) + " "
        if server:
            command += "bash ./scripts-search/NAS-Bench-201/train-a-net-exp.sh "
        else:
            command += "bash ./scripts-search/NAS-Bench-201/train-a-net.sh " 
        command += "'" + network + "' " + str(channel) + " 5"
    return command


# +
num_cells = [6, 8, 10, 12]

def train_a_net_2_command(network, cuda_device=-1, server=False):
    command = ""
    for num_cell in num_cells:
        if command != "":
            command += " && "
        if cuda_device != -1:
            command += "CUDA_VISIBLE_DEVICES=" + str(cuda_device) + " "
        if server:
            command += "bash ./scripts-search/NAS-Bench-201/train-a-net-exp_imagenet.sh "
        else:
            command += "bash ./scripts-search/NAS-Bench-201/train-a-net.sh " 
        command += "'" + network + "' " + "64 " + str(num_cell)
    return command


# -

# cd /netscratch/moser/master_thesis/ && export TORCH_HOME=/netscratch/moser/master_thesis/

srun -p RTX6000 --ntasks 1 -K -N1 --gpus=1 --gpus-per-task=1 --cpus-per-gpu=4 --mem-per-gpu=16G\


s = "|nor_conv_1x1~0|+|nor_conv_1x1~0|skip_connect~1|+|nor_conv_3x3~0|none~1|none~2|+|nor_conv_3x3~0|nor_conv_1x1~1|nor_conv_3x3~2|nor_conv_3x3~3|"
train_a_net_2_command(s, 0, False)

s = "|nor_conv_3x3~0|+|none~0|nor_conv_3x3~1|+|skip_connect~0|nor_conv_3x3~1|nor_conv_3x3~2|+|skip_connect~0|skip_connect~1|nor_conv_1x1~2|nor_conv_3x3~3|"
train_a_net_2_command(s, -1, True)

s = "|skip_connect~0|+|skip_connect~0|skip_connect~1|+|skip_connect~0|avg_pool_3x3~1|avg_pool_3x3~2|+|avg_pool_3x3~0|avg_pool_3x3~1|skip_connect~2|skip_connect~3|"
train_a_net_command(s, -1, True)

s = "|avg_pool_3x3~0|+|skip_connect~0|skip_connect~1|+|avg_pool_3x3~0|skip_connect~1|skip_connect~2|+|avg_pool_3x3~0|avg_pool_3x3~1|avg_pool_3x3~2|skip_connect~3|"
train_a_net_command(s, -1, True)



StarcoderdataJupyterScriptsDedupFiltered