-
Notifications
You must be signed in to change notification settings - Fork 1
/
handcrafted_experiment.sh
executable file
·61 lines (61 loc) · 2.3 KB
/
handcrafted_experiment.sh
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
#!/bin/bash
{
set -euo pipefail
ACTION="$1"
METHOD="$2"
START="$3"
END="$4"
EXE="${BASH_SOURCE%/*}/_build/default/main.exe"
SAVES="${BASH_SOURCE%/*}/saves"
if [[ "${ACTION}" != "train" ]] && [[ "${ACTION}" != "test" ]]; then
echo "Please specify whether to train or test."
exit 1
elif [[ "${METHOD}" != "pcr" ]] && [[ "${METHOD}" != "self" ]] && [[ "${METHOD}" != "hybrid" ]]; then
echo "Please specify the pcr, self or hybrid training method."
exit 1
elif [[ -z "${START}" ]] || [[ -z "${END}" ]]; then
echo "Please specify the start and end number of games."
exit 1
else
for PLAYED in $(eval echo {${START}..$((${END}-10))..10}); do
if [[ "${ACTION}" == "test" ]]; then
PLAYED="$((${PLAYED}+10))"
fi
if [[ "${PLAYED}" == "0" ]]; then
CKPT_TO_LOAD=""
PLAY_TO_LOAD=""
else
CKPT_TO_LOAD="${SAVES}/${METHOD}.${PLAYED}.ckpt"
PLAY_TO_LOAD="${SAVES}/${METHOD}.play"
fi
CKPT_TO_SAVE="${SAVES}/${METHOD}.$((${PLAYED}+10)).ckpt"
PLAY_TO_SAVE="${SAVES}/${METHOD}.play"
TD_CONFIG="((hidden_layer_sizes (40)) (activation Sigmoid) (representation Modified) (ckpt_to_load (${CKPT_TO_LOAD})))"
if [[ "${ACTION}" == "train" ]]; then
REPLAY_MEMORY_CONFIG="((capacity (50_000)) (play_to_load (${PLAY_TO_LOAD})))"
INSTRUCTIONS="((games 10) (train (minibatch_size 128) (minibatches_number 500)) (save_ckpt ${CKPT_TO_SAVE}) (save_play ${PLAY_TO_SAVE}))"
if [[ "${METHOD}" == "pcr" ]] || ([[ "${METHOD}" == "hybrid" ]] && [[ "${PLAYED}" -lt 500 ]]); then
"${EXE}" \
-X "(pip_count_ratio (look_ahead 2))" \
-O "same" \
-train "(td (td_config ${TD_CONFIG}) (replay_memory_config ${REPLAY_MEMORY_CONFIG}))" \
-instructions "${INSTRUCTIONS}" \
else
"${EXE}" \
-X "(td (td_config ${TD_CONFIG}) (look_ahead 2))" \
-O "same" \
-train "(same (replay_memory_config ${REPLAY_MEMORY_CONFIG}))" \
-instructions "${INSTRUCTIONS}" \
-abandon-after "500"
fi
elif [[ "${ACTION}" == "test" ]]; then
echo "After ${PLAYED} games:"
"${EXE}" \
-X "(td (td_config ${TD_CONFIG}) (look_ahead 1))" \
-O "(pip_count_ratio (look_ahead 2))" \
-instructions "((Games 100))" \
fi
done | tee -a "${SAVES}/${METHOD}.${ACTION}.log"
fi
exit 0;
}