Added README.md
[dyncnn.git] / run.sh
diff --git a/run.sh b/run.sh
index fe041f2..3f8529d 100755 (executable)
--- a/run.sh
+++ b/run.sh
@@ -27,55 +27,42 @@ set -o pipefail
 
 [[ "${TORCH_NB_THREADS}" ]] || echo "You can set \$TORCH_NB_THREADS to the proper value (default 1)."
 [[ "${TORCH_USE_GPU}" ]] || echo "You can set \$TORCH_USE_GPU to 'yes' or 'no' (default 'no')."
-[[ "${DYNCNN_DATA_DIR}" ]] || DYNCNN_DATA_DIR="./data/10p-mg"
 
+[[ "${DYNCNN_DATA_DIR}" ]] || DYNCNN_DATA_DIR="./data/10p-mg"
 [[ "${DYNCNN_RUNDIR}" ]] || DYNCNN_RUNDIR="./results"
 
-######################################################################
-# Create the data-set if the directory does not exist
+NB_EPOCHS=2000
 
 if [[ ! -d "${DYNCNN_DATA_DIR}" ]]; then
-    cat <<EOF
-***************************************************************************
-                          Generate the data-set
-***************************************************************************
-EOF
-
+    # Creating the data-base
     make -j -k
     mkdir -p "${DYNCNN_DATA_DIR}"
-    # 17 frames every 16 is two frames: t+0, t+16
+    # 17 frames every 16 is two frames: t+0 and t+16
     ./flatland 40000 \
                --nb_shapes 10 \
-               --multi_grasp --every_nth 16 --nb_frames 17 \
+               --random_grasp --every_nth 16 --nb_frames 17 \
                --dir "${DYNCNN_DATA_DIR}"
 fi
 
-######################################################################
-# Train the model (takes 15h on a GTX 1080 with cuda 8.0, cudnn 5.1,
-# and recent torch)
+# Train the model (2000 epochs takes 30h on a GTX 1080 with cuda 8.0,
+# cudnn 5.1, and recent torch)
 
-if [[ ! -f "${DYNCNN_RUNDIR}"/model_1000.t7 ]]; then
-    cat <<EOF
-***************************************************************************
-                  Train the model (should take a while)
-***************************************************************************
-EOF
-    ./dyncnn.lua -rundir "${DYNCNN_RUNDIR}"
+if [[ -f "$(printf "%s/model_%04d.t7" "${DYNCNN_RUNDIR}" ${NB_EPOCHS})" ]]; then
+    echo "Found the model already trained through ${NB_EPOCHS} epochs."
+else
+    ./dyncnn.lua -nbEpochs ${NB_EPOCHS} -rundir "${DYNCNN_RUNDIR}"
 fi
 
-######################################################################
 # Create the images of internal activations using the current.t7 in
 # the rundir
 
-cat <<EOF
+    cat <<EOF
 ***************************************************************************
-                   Save the internal activation images
+               Creates the images of internal activations
 ***************************************************************************
 EOF
 
-for n in 2 12; do
-    ./dyncnn.lua -rundir "${DYNCNN_RUNDIR}" -noLog -exampleInternals "${n}"
-done
+./dyncnn.lua -rundir "${DYNCNN_RUNDIR}" -noLog -exampleInternals 3,7
 
 ######################################################################
 # Plot the loss curves if gnuplot is here
@@ -83,7 +70,7 @@ done
 if [[ $(which gnuplot) ]]; then
     cat <<EOF
 ***************************************************************************
-                           Plot the loss curves
+                         Plots the loss curves
 ***************************************************************************
 EOF
 
@@ -98,8 +85,8 @@ set logscale y
 set size ratio 0.75
 set xlabel "Number of epochs"
 set ylabel "Loss"
-plot '< grep "LOSS " "${DYNCNN_RUNDIR}"/log' using 4:6 with l lw 3 lc rgb '#c0c0ff' title 'Validation loss',\
-     '< grep "LOSS " "${DYNCNN_RUNDIR}"/log' using 4:5 with l lw 1 lc rgb '#000000' title 'Train loss'
+plot '< grep "acc_train_loss" "${DYNCNN_RUNDIR}"/log' using 4:8 with l lw 3 lc rgb '#c0c0ff' title 'Validation loss',\
+     '< grep "acc_train_loss" "${DYNCNN_RUNDIR}"/log' using 4:6 with l lw 1 lc rgb '#000000' title 'Train loss'
 
 EOF