Skip to content
Snippets Groups Projects
05.1-Full-convolutions-run.ipynb 5.04 KiB
Newer Older
Jean-Luc Parouty's avatar
Jean-Luc Parouty committed
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "German Traffic Sign Recognition Benchmark (GTSRB)\n",
    "=================================================\n",
    "---\n",
    "Introduction au Deep Learning  (IDLE) - S. Arias, E. Maldonado, JL. Parouty - CNRS/SARI/DEVLOG - 2020  \n",
    "\n",
    "## Episode 5.1 : Full Convolutions / run\n",
    "\n",
    "Our main steps:\n",
    " - Run Full-convolution.ipynb as a batch :\n",
    "    - Notebook mode\n",
    "    - Script mode \n",
    " - Tensorboard follow up\n",
    "    \n",
    "## 1/ Run a notebook as a batch\n",
    "To run a notebook :  \n",
    "```jupyter nbconvert --to notebook --execute <notebook>```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Done.\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "# ---- This will execute and save a notebook\n",
    "#\n",
    "jupyter nbconvert --to notebook --execute '05-Full-convolutions.ipynb'\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2/ Export as a script\n",
    "To export a notebook as a script :  \n",
    "```jupyter nbconvert --to script <notebook>```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[NbConvertApp] Converting notebook 05-Full-convolutions.ipynb to script\n",
      "[NbConvertApp] Writing 8775 bytes to 05-Full-convolutions.py\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "\n",
    "# ---- This will convert notebook to a notebook.py script\n",
    "#\n",
    "jupyter nbconvert --to script '05-Full-convolutions.ipynb'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total 8156\n",
      "-rw-r--r-- 1 pjluc pjluc   16893 Jan 19 15:07 01-Preparation-of-data.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc    9181 Jan 19 15:08 02-First-convolutions.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc   12879 Jan 19 15:09 03-Tracking-and-visualizing.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc   10667 Jan 19 15:10 04-Data-augmentation.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc    3325 Jan 19 15:50 05.1-Full-convolutions-run.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc   19865 Jan 19 15:17 05.2-Full-convolutions-reports.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc   14466 Jan 19 15:11 05-Full-convolutions.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc   14533 Jan 19 15:35 05-Full-convolutions.nbconvert.ipynb\n",
      "-rw-r--r-- 1 pjluc pjluc    8775 Jan 19 15:43 05-Full-convolutions.py\n",
      "-rw-r--r-- 1 pjluc pjluc   12346 Jan 19 15:47 99 Scripts-Tensorboard.ipynb\n",
      "drwxr-xr-x 1 pjluc pjluc     512 Jan 10 22:10 data\n",
      "drwxr-xr-x 1 pjluc pjluc     512 Jan 19 15:07 fidle\n",
      "-rw-r--r-- 1 pjluc pjluc 7391072 Jan 19 00:41 foo.h5\n",
      "-rw-r--r-- 1 pjluc pjluc    2816 Jan 11 15:45 README.ipynb\n",
      "drwxr-xr-x 1 pjluc pjluc     512 Jan 19 15:35 run\n"
     ]
    }
   ],
   "source": [
    "!ls -l"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3/ Batch submission\n",
    "Create batch script :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing ./run/batch_full_convolutions.sh\n"
     ]
    }
   ],
   "source": [
    "%%writefile \"./run/batch_full_convolutions.sh\"\n",
    "\n",
    "#!/bin/batch\n",
    "\n",
    "# ----------------------------------\n",
    "#   _           _       _\n",
    "#  | |__   __ _| |_ ___| |__\n",
    "#  | '_ \\ / _` | __/ __| '_ \\\n",
    "#  | |_) | (_| | || (__| | | |\n",
    "#  |_.__/ \\__,_|\\__\\___|_| |_|\n",
    "#                  Full convolutions\n",
    "# ----------------------------------\n",
    "#\n",
    "CONDA_ENV=\"deeplearning2\"\n",
    "RUN_DIR=\"~/fidle/GTSRB\"\n",
    "RUN_SCRIPT=\"05-Full-convolutions.py\"\n",
    "\n",
    "# ---- Cuda Conda initialization\n",
    "#\n",
    "echo -e 'Init environment with cuda and conda...\\n'\n",
    "source /applis/environments/cuda_env.sh dahu 10.0\n",
    "source /applis/environments/conda.sh\n",
    "#\n",
    "conda activate \"$CONDA_ENV\"\n",
    "\n",
    "# ---- Run it...\n",
    "#\n",
    "cd $RUN_DIR\n",
    "$RUN_SCRIPT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}