-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrdunet_trainer.slurm
More file actions
77 lines (63 loc) · 2.25 KB
/
rdunet_trainer.slurm
File metadata and controls
77 lines (63 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash -l
#
#SBATCH --gres=gpu:v100:1
#SBATCH --partition=v100
#SBATCH --time=24:00:00
#SBATCH --export=NONE
#SBATCH --output=rdunet_trainer.out
unset SLURM_EXPORT_ENV
module load python
conda activate pytorch
# export proxy
export http_proxy=http://proxy:80
export https_proxy=http://proxy:80
pip install -e .
echo "Copying compressed adversarial files to TMPDIR"
# Use the predefined directories
export DATA_DIR="$TMPDIR"
export PROJECT_DIR="$HOME/advisg"
target_root="$DATA_DIR/adv_samples"
mkdir -p "$target_root"
adversarial_root="$PROJECT_DIR/results/adversarial_attacks/resnet18_nosampling"
# Copy and unzip all train and val zip files for each subfolder
for subfolder in "$adversarial_root"/*; do
if [ -d "$subfolder" ]; then
name=$(basename "$subfolder")
for split in train val; do
zip_file="${subfolder}/${name}_${split}.zip"
dest_dir="${target_root}/${name}/${split}"
mkdir -p "$dest_dir"
if [ -f "$zip_file" ]; then
echo "Unzipping $zip_file to $dest_dir"
unzip -q "$zip_file" -d "$dest_dir"
else
echo "Warning: $zip_file not found."
fi
done
fi
done
adversarial_root="$PROJECT_DIR/results/adversarial_attacks/mobilenet_v3_large_nosampling"
# Copy and unzip all train and val zip files for each subfolder
for subfolder in "$adversarial_root"/*; do
if [ -d "$subfolder" ]; then
name=$(basename "$subfolder")
for split in train val; do
zip_file="${subfolder}/${name}_${split}.zip"
dest_dir="${target_root}/${name}/${split}"
mkdir -p "$dest_dir"
if [ -f "$zip_file" ]; then
echo "Unzipping $zip_file to $dest_dir"
unzip -q "$zip_file" -d "$dest_dir"
else
echo "Warning: $zip_file not found."
fi
done
fi
done
# echo "All adversarial files prepared in $target_root"
export BATCH_SIZE=16
python3 $HOME/advisg/trainers/session_ae_trainer.py --data_dir "$DATA_DIR" --project_dir "$PROJECT_DIR" --ae_type rdunet --batch_size "$BATCH_SIZE" --data_type normal
# Clean up: delete the target_root directory
echo "Cleaning up $target_root"
rm -rf "$target_root"
echo "Cleanup complete."