You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.7 KiB

import subprocess
import sys
11 months ago
from random import sample
import numpy as np
from lightning_sdk import Machine, Studio # noqa: F401
11 months ago
10 months ago
NUM_JOBS = 100
11 months ago
# reference to the current studio
# if you run outside of Lightning, you can pass the Studio name
10 months ago
# studio = Studio()
11 months ago
# use the jobs plugin
10 months ago
# studio.install_plugin("jobs")
# job_plugin = studio.installed_plugins["jobs"]
11 months ago
# do a sweep over learning rates
# Define the ranges or sets of values for each hyperparameter
10 months ago
# alpha_values = list(np.round(np.linspace(2, 4, 21), 4))
10 months ago
# learning_rate_values = list(np.round(np.logspace(-5, -3, 21), 5))
10 months ago
learning_rate_values = [1e-2, 1e-3]
alpha_values = [0, 1, 2]
widths = [64, 128, 256, 512]
# learning_rate_values = [5e-4]
10 months ago
batch_size_values = [8192]
max_epochs_values = [50]
10 months ago
seeds = list(range(21, 1992))
11 months ago
# Generate all possible combinations of hyperparameters
11 months ago
all_params = [
(alpha, lr, bs, me, s, w)
11 months ago
for alpha in alpha_values
for lr in learning_rate_values
for bs in batch_size_values
for me in max_epochs_values
10 months ago
for s in seeds
for w in widths
11 months ago
]
11 months ago
# perform random search with a limit
search_params = sample(all_params, min(NUM_JOBS, len(all_params)))
11 months ago
for idx, params in enumerate(search_params):
a, lr, bs, me, s, w = params
cmd = f"cd ~/colors && python main.py --alpha {a} --lr {lr} --bs {bs} --max_epochs {me} --seed {s} --width {w}"
10 months ago
# job_name = f"color2_{bs}_{a}_{lr:2.2e}"
11 months ago
# job_plugin.run(cmd, machine=Machine.T4, name=job_name)
print(f"Running {params}: {cmd}")
try:
# Run the command and wait for it to complete
subprocess.run(cmd, shell=True, check=True)
except KeyboardInterrupt:
print("Interrupted by user")
sys.exit(1)