AlexKM commited on
Commit
78f2b0a
1 Parent(s): 6be96ac

Upload opt_tester.sh

Browse files
Files changed (1) hide show
  1. opt_tester.sh +53 -0
opt_tester.sh ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Using each optimiser, generate images using a range of learning rates
4
+ # Produce a labelled montage to easily view the results
5
+
6
+ TEXT="A painting in the style of Paul Gauguin"
7
+ OUT_DIR="/home/nerdy/github/VQGAN-CLIP/Saves/OptimiserTesting-60it-Noise-NPW-1"
8
+ ITERATIONS=60
9
+ SAVE_EVERY=60
10
+ HEIGHT=256
11
+ WIDTH=256
12
+ SEED=`shuf -i 1-9999999999 -n 1` # Keep the same seed each epoch for more deterministic runs
13
+
14
+ # Main
15
+ #################
16
+
17
+ export CUBLAS_WORKSPACE_CONFIG=:4096:8
18
+ mkdir -p "$OUT_DIR"
19
+
20
+ function do_optimiser_test () {
21
+ OPTIMISER="$1"
22
+ LR="$2"
23
+ STEP="$3"
24
+ NPW="$4"
25
+ for i in {1..10}
26
+ do
27
+ PADDED_COUNT=$(printf "%03d" "$COUNT")
28
+ echo "Loop for $OPTIMISER - $LR"
29
+ python generate.py -p "$TEXT" -in pixels -o "$OUT_DIR"/"$PADDED_COUNT"-"$OPTIMISER"-"$LR"-"$NPW".png -opt "$OPTIMISER" -lr "$LR" -i "$ITERATIONS" -se "$SAVE_EVERY" -s "$HEIGHT" "$WIDTH" --seed "$SEED" -d True -iw 1 -nps 666 -npw "$NPW" -d True
30
+ LR=$(echo $LR + $STEP | bc)
31
+ ((COUNT++))
32
+ done
33
+ }
34
+
35
+ # Test optimisers
36
+ COUNT=0
37
+ do_optimiser_test "Adam" .1 .1 1
38
+ COUNT=10
39
+ do_optimiser_test "AdamW" .1 .1 1
40
+ COUNT=20
41
+ do_optimiser_test "Adamax" .1 .1 1
42
+ COUNT=30
43
+ do_optimiser_test "Adagrad" .1 .25 1
44
+ COUNT=40
45
+ do_optimiser_test "AdamP" .1 .25 1
46
+ COUNT=50
47
+ do_optimiser_test "RAdam" .1 .25 1
48
+ COUNT=60
49
+ do_optimiser_test "DiffGrad" .1 .25 1
50
+
51
+ # Make montage
52
+ mogrify -font Liberation-Sans -fill white -undercolor '#00000080' -pointsize 14 -gravity NorthEast -annotate +10+10 %t "$OUT_DIR"/*.png
53
+ montage "$OUT_DIR"/*.png -geometry 256x256+1+1 -tile 10x7 collage.jpg