Automating Ablation Studies of Deep Learning Models using Batch Script

In this article, we will look at a short example of how we can automate running ablation study experiments on our deep learning models using batch scripts in Windows.

Step 1

Create a .bat file in your editor

Step 2: Identify the hyper-parameters you want to sweep over in your experiments

For this article, let us consider the hyper-parameter to be λ. Also, we would like to see the effect of batch size for each λ value.

@echo off
setlocal EnableDelayedExpansion
set lambda=2 10 50 100
set bs=128 256 512
set /a exprun = 1
for %%i in (%lambda%) do (
    for %%j in (%bs%) do (
        echo lambda=%%i/100
        echo bs=%%j
        set /a exprun=!exprun!+1
        echo !exprun!
        python train.py --lambda %%i --bs %%j --run !exprun!
    )
)
endlocal

In the above code, we pass the arguments lambda and bs to the python file trian.py and also increment our experiment number counter exprun.

Read More

Tags: Batch script