Skip to content

Commit

Permalink
Scripts to execute in the GPU cluster advances #26
Browse files Browse the repository at this point in the history
  • Loading branch information
pab1s committed May 28, 2024
1 parent 9b66a17 commit 7416cdb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ifndef CONDA
endif
@echo "Creating the Conda environment if it doesn't exist..."
@conda env list | grep -q '^$(ENV_NAME) ' || \
conda create --yes --name $(ENV_NAME) python=$(PYTHON_VERSION)
conda create --yes --prefix $(ENV_NAME) python=$(PYTHON_VERSION)

# Install packages from an environment file or manually specified
.PHONY: install
Expand Down
40 changes: 40 additions & 0 deletions scripts/create_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Define the ranges for each parameter
learning_rates=(0.0001 0.001 0.01)
batch_sizes=(16 32 64)
num_epochs=(2 5 10)
optimizers=(Adam RMSProp SGD)
loss_functions=(CrossEntropyLoss MeanSquaredError)

# Define the config file and output directory
config_file="config.yaml"
output_dir="experiments"

# Create the output directory if it doesn't exist
mkdir -p "$output_dir"

# Loop through each combination of parameters
for lr in "${learning_rates[@]}"; do
for bs in "${batch_sizes[@]}"; do
for ne in "${num_epochs[@]}"; do
for opt in "${optimizers[@]}"; do
for lf in "${loss_functions[@]}"; do
# Create a new config file with the modified parameters
new_config_file="$output_dir/config_lr_${lr}_bs_${bs}_ne_${ne}_opt_${opt}_lf_${lf}.yaml"
cp "$config_file" "$new_config_file"

# Modify the parameters in the new config file
sed -i "s/learning_rate:.*/learning_rate: $lr/" "$new_config_file"
sed -i "s/batch_size:.*/batch_size: $bs/" "$new_config_file"
sed -i "s/num_epochs:.*/num_epochs: $ne/" "$new_config_file"
sed -i "s/optimizer:.*/optimizer:\n type: \"$opt\"/" "$new_config_file"
sed -i "s/loss_function:.*/loss_function:\n type: \"$lf\"/" "$new_config_file"

# Run the training process with the new config file
python train.py --config "$new_config_file"
done
done
done
done
done
23 changes: 23 additions & 0 deletions scripts/find_learning_rates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

#SBATCH --job-name LR_EfficientNetB0 # Nombre del proceso

#SBATCH --partition dios # Cola para ejecutar

#SBATCH --gres=gpu:1 # Numero de gpus a usar



export PATH="/opt/anaconda/anaconda3/bin:$PATH"

export PATH="/opt/anaconda/bin:$PATH"

eval "$(conda shell.bash hook)"

conda activate /mnt/homeGPU/polivares/tda-nn-separability

export TFHUB_CACHE_DIR=.

python find_learning_rates.py

mail -s "Proceso finalizado" [email protected] <<< "El proceso ha finalizado"

0 comments on commit 7416cdb

Please sign in to comment.