From 0d56f8fcacce07aea46cf5e2a1b386d514845727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=B6ger?= Date: Wed, 28 Apr 2021 16:20:39 +0200 Subject: [PATCH] DeadReluCallback improved (#4) * added first callback activation callback * restructuring * added dead relu detector * Update README.md * Update README.md * Update README.md * added GradCAM and worked on sample implementation * added possibility to log all n epochs * worked on docs * deadrelu now also logs mean --- .github/workflows/docs_pages_workflow.yml | 29 ++ notebooks/sample_implementation.ipynb | 371 +++++++++++++++------- wandb_callbacks/tensorflow.py | 22 +- 3 files changed, 310 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/docs_pages_workflow.yml diff --git a/.github/workflows/docs_pages_workflow.yml b/.github/workflows/docs_pages_workflow.yml new file mode 100644 index 0000000..d063ac3 --- /dev/null +++ b/.github/workflows/docs_pages_workflow.yml @@ -0,0 +1,29 @@ +name: docs_pages_workflow + +# execute this workflow automatically when a we push to master +on: + push: + branches: [ master ] + +jobs: + + build_docs_job: + runs-on: ubuntu-latest + container: debian:buster-slim + + steps: + + - name: Prereqs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + apt-get update + apt-get install -y git + git clone --depth 1 "https://token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" . + shell: bash + + - name: Execute script to build our documentation and update pages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: "docs/buildDocs.sh" + shell: bash diff --git a/notebooks/sample_implementation.ipynb b/notebooks/sample_implementation.ipynb index 5d781bb..7e2cafe 100644 --- a/notebooks/sample_implementation.ipynb +++ b/notebooks/sample_implementation.ipynb @@ -18,72 +18,74 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: matplotlib==3.3.2 in /opt/conda/lib/python3.8/site-packages (from -r ../requirements.txt (line 1)) (3.3.2)\n", - "Requirement already satisfied: wandb==0.10.27 in /opt/conda/lib/python3.8/site-packages (from -r ../requirements.txt (line 2)) (0.10.27)\n", - "Requirement already satisfied: opencv_python==4.5.1.48 in /opt/conda/lib/python3.8/site-packages (from -r ../requirements.txt (line 3)) (4.5.1.48)\n", - "Requirement already satisfied: numpy==1.19.4 in /opt/conda/lib/python3.8/site-packages (from -r ../requirements.txt (line 4)) (1.19.4)\n", - "Requirement already satisfied: tensorflow>=2.1.0 in /opt/conda/lib/python3.8/site-packages (from -r ../requirements.txt (line 5)) (2.4.1)\n", - "Requirement already satisfied: pillow>=6.2.0 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (7.2.0)\n", - "Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2.8.1)\n", - "Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (0.10.0)\n", - "Requirement already satisfied: certifi>=2020.06.20 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2020.6.20)\n", - "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2.4.7)\n", - "Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.8/site-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (1.2.0)\n", - "Requirement already satisfied: sentry-sdk>=0.4.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.0.0)\n", - "Requirement already satisfied: GitPython>=1.0.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.1.14)\n", - "Requirement already satisfied: promise<3,>=2.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (2.3)\n", - "Requirement already satisfied: six>=1.13.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.15.0)\n", - "Requirement already satisfied: psutil>=5.0.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.7.2)\n", - "Requirement already satisfied: configparser>=3.8.1 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.0.2)\n", - "Requirement already satisfied: requests<3,>=2.0.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (2.24.0)\n", - "Requirement already satisfied: shortuuid>=0.5.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.0.1)\n", - "Requirement already satisfied: subprocess32>=3.5.3 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.5.4)\n", - "Requirement already satisfied: docker-pycreds>=0.4.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (0.4.0)\n", - "Requirement already satisfied: protobuf>=3.12.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.12.4)\n", - "Requirement already satisfied: PyYAML in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.3.1)\n", - "Requirement already satisfied: pathtools in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (0.1.2)\n", - "Requirement already satisfied: Click>=7.0 in /opt/conda/lib/python3.8/site-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (7.1.2)\n", - "Requirement already satisfied: wheel~=0.35 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.35.1)\n", - "Requirement already satisfied: gast==0.3.3 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.3.3)\n", - "Requirement already satisfied: grpcio~=1.32.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.32.0)\n", - "Requirement already satisfied: termcolor~=1.1.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.1.0)\n", - "Requirement already satisfied: typing-extensions~=3.7.4 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.7.4.2)\n", - "Requirement already satisfied: wrapt~=1.12.1 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.12.1)\n", - "Requirement already satisfied: keras-preprocessing~=1.1.2 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.1.2)\n", - "Requirement already satisfied: google-pasta~=0.2 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.2.0)\n", - "Requirement already satisfied: astunparse~=1.6.3 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.6.3)\n", - "Requirement already satisfied: flatbuffers~=1.12.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.12)\n", - "Requirement already satisfied: opt-einsum~=3.3.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.3.0)\n", - "Requirement already satisfied: tensorflow-estimator<2.5.0,>=2.4.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.4.0)\n", - "Requirement already satisfied: tensorboard~=2.4 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.5.0)\n", - "Requirement already satisfied: absl-py~=0.10 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.12.0)\n", - "Requirement already satisfied: h5py~=2.10.0 in /opt/conda/lib/python3.8/site-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.10.0)\n", - "Requirement already satisfied: gitdb<5,>=4.0.1 in /opt/conda/lib/python3.8/site-packages (from GitPython>=1.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (4.0.7)\n", - "Requirement already satisfied: smmap<5,>=3.0.1 in /opt/conda/lib/python3.8/site-packages (from gitdb<5,>=4.0.1->GitPython>=1.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (4.0.0)\n", - "Requirement already satisfied: setuptools in /opt/conda/lib/python3.8/site-packages (from protobuf>=3.12.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (49.6.0.post20201009)\n", - "Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/lib/python3.8/site-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (3.0.4)\n", - "Requirement already satisfied: idna<3,>=2.5 in /opt/conda/lib/python3.8/site-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (2.10)\n", - "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.8/site-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (1.25.10)\n", - "Requirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.6.0)\n", - "Requirement already satisfied: markdown>=2.6.8 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.3.4)\n", - "Requirement already satisfied: google-auth<2,>=1.6.3 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.30.0)\n", - "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.8.0)\n", - "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.4.4)\n", - "Requirement already satisfied: werkzeug>=0.11.15 in /opt/conda/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.0.1)\n", - "Requirement already satisfied: pyasn1-modules>=0.2.1 in /opt/conda/lib/python3.8/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.2.8)\n", - "Requirement already satisfied: rsa<5,>=3.1.4 in /opt/conda/lib/python3.8/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (4.7.2)\n", - "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /opt/conda/lib/python3.8/site-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (4.2.2)\n", - "Requirement already satisfied: requests-oauthlib>=0.7.0 in /opt/conda/lib/python3.8/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.3.0)\n", - "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /opt/conda/lib/python3.8/site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.4.8)\n", - "Requirement already satisfied: oauthlib>=3.0.0 in /opt/conda/lib/python3.8/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.0.1)\n" + "Requirement already satisfied: matplotlib==3.3.2 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 1)) (3.3.2)\n", + "Requirement already satisfied: wandb==0.10.27 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 2)) (0.10.27)\n", + "Requirement already satisfied: opencv_python==4.5.1.48 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 3)) (4.5.1.48)\n", + "Requirement already satisfied: numpy==1.19.4 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 4)) (1.19.4)\n", + "Requirement already satisfied: tensorflow>=2.1.0 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 5)) (2.4.1)\n", + "Requirement already satisfied: pip==21.0.1 in /usr/local/lib/python3.6/dist-packages (from -r ../requirements.txt (line 6)) (21.0.1)\n", + "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (0.10.0)\n", + "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2.4.7)\n", + "Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (8.1.0)\n", + "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2.8.1)\n", + "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (1.3.1)\n", + "Requirement already satisfied: certifi>=2020.06.20 in /usr/local/lib/python3.6/dist-packages (from matplotlib==3.3.2->-r ../requirements.txt (line 1)) (2020.12.5)\n", + "Requirement already satisfied: sentry-sdk>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.0.0)\n", + "Requirement already satisfied: GitPython>=1.0.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.1.14)\n", + "Requirement already satisfied: psutil>=5.0.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.8.0)\n", + "Requirement already satisfied: protobuf>=3.12.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.14.0)\n", + "Requirement already satisfied: Click>=7.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (7.1.2)\n", + "Requirement already satisfied: subprocess32>=3.5.3 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (3.5.4)\n", + "Requirement already satisfied: configparser>=3.8.1 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.0.2)\n", + "Requirement already satisfied: six>=1.13.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.15.0)\n", + "Requirement already satisfied: pathtools in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (0.1.2)\n", + "Requirement already satisfied: promise<3,>=2.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (2.3)\n", + "Requirement already satisfied: requests<3,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (2.25.1)\n", + "Requirement already satisfied: docker-pycreds>=0.4.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (0.4.0)\n", + "Requirement already satisfied: shortuuid>=0.5.0 in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (1.0.1)\n", + "Requirement already satisfied: PyYAML in /usr/local/lib/python3.6/dist-packages (from wandb==0.10.27->-r ../requirements.txt (line 2)) (5.4.1)\n", + "Requirement already satisfied: google-pasta~=0.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.2.0)\n", + "Requirement already satisfied: astunparse~=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.6.3)\n", + "Requirement already satisfied: flatbuffers~=1.12.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.12)\n", + "Requirement already satisfied: absl-py~=0.10 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.11.0)\n", + "Requirement already satisfied: wrapt~=1.12.1 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.12.1)\n", + "Requirement already satisfied: h5py~=2.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.10.0)\n", + "Requirement already satisfied: wheel~=0.35 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.36.2)\n", + "Requirement already satisfied: termcolor~=1.1.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.1.0)\n", + "Requirement already satisfied: grpcio~=1.32.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.32.0)\n", + "Requirement already satisfied: typing-extensions~=3.7.4 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.7.4.3)\n", + "Requirement already satisfied: keras-preprocessing~=1.1.2 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.1.2)\n", + "Requirement already satisfied: tensorflow-estimator<2.5.0,>=2.4.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.4.0)\n", + "Requirement already satisfied: tensorboard~=2.4 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (2.4.1)\n", + "Requirement already satisfied: opt-einsum~=3.3.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.3.0)\n", + "Requirement already satisfied: gast==0.3.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.3.3)\n", + "Requirement already satisfied: gitdb<5,>=4.0.1 in /usr/local/lib/python3.6/dist-packages (from GitPython>=1.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (4.0.7)\n", + "Requirement already satisfied: smmap<5,>=3.0.1 in /usr/local/lib/python3.6/dist-packages (from gitdb<5,>=4.0.1->GitPython>=1.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (4.0.0)\n", + "Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3/dist-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (2.6)\n", + "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (1.26.2)\n", + "Requirement already satisfied: chardet<5,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests<3,>=2.0.0->wandb==0.10.27->-r ../requirements.txt (line 2)) (4.0.0)\n", + "Requirement already satisfied: werkzeug>=0.11.15 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.0.1)\n", + "Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.3.3)\n", + "Requirement already satisfied: google-auth<2,>=1.6.3 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.24.0)\n", + "Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (51.3.3)\n", + "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.8.0)\n", + "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in /usr/local/lib/python3.6/dist-packages (from tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.4.2)\n", + "Requirement already satisfied: cachetools<5.0,>=2.0.0 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (4.2.0)\n", + "Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (4.7)\n", + "Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.6/dist-packages (from google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.2.8)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 21.1 is available.\r\n", - "You should consider upgrading via the '/opt/conda/bin/python3.8 -m pip install --upgrade pip' command.\u001b[0m\r\n" + "Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (1.3.0)\n", + "Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.6/dist-packages (from markdown>=2.6.8->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.4.0)\n", + "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in /usr/local/lib/python3.6/dist-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (0.4.8)\n", + "Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.6/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.1.0)\n", + "Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata->markdown>=2.6.8->tensorboard~=2.4->tensorflow>=2.1.0->-r ../requirements.txt (line 5)) (3.4.0)\n", + "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 21.1 is available.\n", + "You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n" ] } ], @@ -95,6 +97,26 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: opencv-python-headless in /usr/local/lib/python3.6/dist-packages (4.5.1.48)\n", + "Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from opencv-python-headless) (1.19.4)\n", + "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 21.1 is available.\n", + "You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install opencv-python-headless" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -118,7 +140,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -127,6 +149,13 @@ "text": [ "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mfabiangroeger\u001b[0m (use `wandb login --relogin` to force relogin)\n" ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 Physical GPUs, 1 Logical GPUs\n" + ] } ], "source": [ @@ -173,7 +202,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -211,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -248,7 +277,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -261,7 +290,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -269,10 +298,10 @@ "text/html": [ "\n", " Tracking run with wandb version 0.10.27
\n", - " Syncing run sparkling-yogurt-69 to Weights & Biases (Documentation).
\n", + " Syncing run silver-pyramid-74 to Weights & Biases (Documentation).
\n", " Project page: https://wandb.ai/fabiangroeger/wandb-callbacks-demo
\n", - " Run page: https://wandb.ai/fabiangroeger/wandb-callbacks-demo/runs/2ou4tma7
\n", - " Run data is saved locally in /home/jovyan/work/Documents/_git/GitHub/wandb-callbacks/notebooks/wandb/run-20210428_072411-2ou4tma7

\n", + " Run page: https://wandb.ai/fabiangroeger/wandb-callbacks-demo/runs/5lu82o0p
\n", + " Run data is saved locally in /tf/notebooks/GitHub/wandb-callbacks/notebooks/wandb/run-20210428_141217-5lu82o0p

\n", " " ], "text/plain": [ @@ -355,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "scrolled": true }, @@ -365,68 +394,192 @@ "output_type": "stream", "text": [ "Epoch 1/30\n", - "782/782 [==============================] - 47s 60ms/step - loss: 1.8943 - accuracy: 0.3006 - val_loss: 1.4248 - val_accuracy: 0.4813\n", - "logging\n", + " 1/782 [..............................] - ETA: 25:38 - loss: 3.3515 - accuracy: 0.0938WARNING:tensorflow:Callback method `on_train_batch_end` is slow compared to the batch time (batch time: 0.0031s vs `on_train_batch_end` time: 0.0034s). Check your callbacks.\n", + "782/782 [==============================] - 6s 5ms/step - loss: 1.8756 - accuracy: 0.3205 - val_loss: 1.3585 - val_accuracy: 0.5026\n", + "Layer conv2d (#0) has 12.0 dead neurons (37.50%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 22.0 dead neurons (34.38%)!\n", + "Layer conv2d_3 (#5) has 104.0 dead neurons (81.25%)!\n", "Epoch 2/30\n", - "782/782 [==============================] - 46s 59ms/step - loss: 1.3477 - accuracy: 0.5146 - val_loss: 1.2994 - val_accuracy: 0.5430\n", + "782/782 [==============================] - 3s 4ms/step - loss: 1.2451 - accuracy: 0.5548 - val_loss: 1.2294 - val_accuracy: 0.5671\n", + "Layer conv2d (#0) has 15.0 dead neurons (46.88%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 24.0 dead neurons (37.50%)!\n", + "Layer conv2d_3 (#5) has 98.0 dead neurons (76.56%)!\n", "Epoch 3/30\n", - "782/782 [==============================] - 46s 59ms/step - loss: 1.2355 - accuracy: 0.5635 - val_loss: 1.1928 - val_accuracy: 0.5809\n", + "782/782 [==============================] - 3s 4ms/step - loss: 1.1029 - accuracy: 0.6108 - val_loss: 1.1416 - val_accuracy: 0.6020\n", + "Layer conv2d (#0) has 15.0 dead neurons (46.88%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 22.0 dead neurons (34.38%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 4/30\n", - "782/782 [==============================] - 48s 61ms/step - loss: 1.1191 - accuracy: 0.6071 - val_loss: 1.1727 - val_accuracy: 0.5909\n", + "782/782 [==============================] - 3s 4ms/step - loss: 1.0118 - accuracy: 0.6450 - val_loss: 1.0690 - val_accuracy: 0.6253\n", + "Layer conv2d (#0) has 20.0 dead neurons (62.50%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 22.0 dead neurons (34.38%)!\n", + "Layer conv2d_3 (#5) has 101.0 dead neurons (78.91%)!\n", "Epoch 5/30\n", - "782/782 [==============================] - 49s 62ms/step - loss: 1.0802 - accuracy: 0.6213 - val_loss: 1.2251 - val_accuracy: 0.5902\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.9626 - accuracy: 0.6618 - val_loss: 1.0569 - val_accuracy: 0.6363\n", + "Layer conv2d (#0) has 20.0 dead neurons (62.50%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 23.0 dead neurons (35.94%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 6/30\n", - "782/782 [==============================] - 45s 57ms/step - loss: 1.0204 - accuracy: 0.6401 - val_loss: 1.1216 - val_accuracy: 0.6118\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.9175 - accuracy: 0.6787 - val_loss: 1.1178 - val_accuracy: 0.6264\n", + "Layer conv2d (#0) has 20.0 dead neurons (62.50%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 25.0 dead neurons (39.06%)!\n", + "Layer conv2d_3 (#5) has 101.0 dead neurons (78.91%)!\n", "Epoch 7/30\n", - "782/782 [==============================] - 43s 56ms/step - loss: 0.9806 - accuracy: 0.6590 - val_loss: 1.1408 - val_accuracy: 0.6143\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8904 - accuracy: 0.6865 - val_loss: 1.0563 - val_accuracy: 0.6378\n", + "Layer conv2d (#0) has 21.0 dead neurons (65.62%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 97.0 dead neurons (75.78%)!\n", "Epoch 8/30\n", - "782/782 [==============================] - 45s 57ms/step - loss: 0.9362 - accuracy: 0.6708 - val_loss: 1.1270 - val_accuracy: 0.6125\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8911 - accuracy: 0.6858 - val_loss: 1.0474 - val_accuracy: 0.6363\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 19.0 dead neurons (29.69%)!\n", + "Layer conv2d_3 (#5) has 98.0 dead neurons (76.56%)!\n", "Epoch 9/30\n", - "782/782 [==============================] - 50s 64ms/step - loss: 0.9059 - accuracy: 0.6829 - val_loss: 1.1592 - val_accuracy: 0.6111\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8627 - accuracy: 0.7008 - val_loss: 1.0584 - val_accuracy: 0.6453\n", + "Layer conv2d (#0) has 21.0 dead neurons (65.62%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 23.0 dead neurons (35.94%)!\n", + "Layer conv2d_3 (#5) has 96.0 dead neurons (75.00%)!\n", "Epoch 10/30\n", - "782/782 [==============================] - 54s 69ms/step - loss: 0.9084 - accuracy: 0.6854 - val_loss: 1.1743 - val_accuracy: 0.6007\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8460 - accuracy: 0.7021 - val_loss: 1.0722 - val_accuracy: 0.6386\n", + "Layer conv2d (#0) has 21.0 dead neurons (65.62%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 20.0 dead neurons (31.25%)!\n", + "Layer conv2d_3 (#5) has 99.0 dead neurons (77.34%)!\n", "Epoch 11/30\n", - "782/782 [==============================] - 53s 67ms/step - loss: 0.8656 - accuracy: 0.6935 - val_loss: 1.1179 - val_accuracy: 0.6211\n", - "logging\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8187 - accuracy: 0.7147 - val_loss: 1.0842 - val_accuracy: 0.6420\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 108.0 dead neurons (84.38%)!\n", "Epoch 12/30\n", - "782/782 [==============================] - 47s 61ms/step - loss: 0.8425 - accuracy: 0.7039 - val_loss: 1.2024 - val_accuracy: 0.6054\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.8031 - accuracy: 0.7215 - val_loss: 1.0537 - val_accuracy: 0.6472\n", + "Layer conv2d (#0) has 21.0 dead neurons (65.62%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 24.0 dead neurons (37.50%)!\n", + "Layer conv2d_3 (#5) has 103.0 dead neurons (80.47%)!\n", "Epoch 13/30\n", - "782/782 [==============================] - 42s 54ms/step - loss: 0.8251 - accuracy: 0.7091 - val_loss: 1.1469 - val_accuracy: 0.6195\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7886 - accuracy: 0.7197 - val_loss: 1.0761 - val_accuracy: 0.6407\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_2 (#3) has 22.0 dead neurons (34.38%)!\n", + "Layer conv2d_3 (#5) has 101.0 dead neurons (78.91%)!\n", "Epoch 14/30\n", - "782/782 [==============================] - 49s 63ms/step - loss: 0.8062 - accuracy: 0.7133 - val_loss: 1.1575 - val_accuracy: 0.6244\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7775 - accuracy: 0.7236 - val_loss: 1.0786 - val_accuracy: 0.6423\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 21.0 dead neurons (32.81%)!\n", + "Layer conv2d_3 (#5) has 99.0 dead neurons (77.34%)!\n", "Epoch 15/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.8039 - accuracy: 0.7186 - val_loss: 1.1571 - val_accuracy: 0.6264\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7818 - accuracy: 0.7273 - val_loss: 1.0532 - val_accuracy: 0.6536\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 105.0 dead neurons (82.03%)!\n", "Epoch 16/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.7839 - accuracy: 0.7243 - val_loss: 1.2033 - val_accuracy: 0.6146\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7547 - accuracy: 0.7336 - val_loss: 1.0757 - val_accuracy: 0.6405\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 19.0 dead neurons (29.69%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 17/30\n", - "782/782 [==============================] - 51s 66ms/step - loss: 0.7572 - accuracy: 0.7371 - val_loss: 1.2381 - val_accuracy: 0.6130\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7494 - accuracy: 0.7356 - val_loss: 1.0965 - val_accuracy: 0.6407\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 101.0 dead neurons (78.91%)!\n", "Epoch 18/30\n", - "782/782 [==============================] - 51s 66ms/step - loss: 0.7478 - accuracy: 0.7405 - val_loss: 1.1888 - val_accuracy: 0.6208\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7443 - accuracy: 0.7373 - val_loss: 1.1540 - val_accuracy: 0.6331\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 98.0 dead neurons (76.56%)!\n", "Epoch 19/30\n", - "782/782 [==============================] - 53s 67ms/step - loss: 0.7433 - accuracy: 0.7397 - val_loss: 1.2385 - val_accuracy: 0.6110\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7277 - accuracy: 0.7439 - val_loss: 1.1229 - val_accuracy: 0.6417\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 97.0 dead neurons (75.78%)!\n", "Epoch 20/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.7275 - accuracy: 0.7438 - val_loss: 1.1812 - val_accuracy: 0.6228\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7083 - accuracy: 0.7512 - val_loss: 1.1319 - val_accuracy: 0.6390\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 19.0 dead neurons (29.69%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 21/30\n", - "782/782 [==============================] - 52s 66ms/step - loss: 0.7159 - accuracy: 0.7491 - val_loss: 1.2572 - val_accuracy: 0.6060\n", - "logging\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.7258 - accuracy: 0.7421 - val_loss: 1.1333 - val_accuracy: 0.6369\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 17.0 dead neurons (26.56%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 22/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.6998 - accuracy: 0.7507 - val_loss: 1.2536 - val_accuracy: 0.6174\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6914 - accuracy: 0.7561 - val_loss: 1.1724 - val_accuracy: 0.6296\n", + "Layer conv2d (#0) has 21.0 dead neurons (65.62%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 101.0 dead neurons (78.91%)!\n", "Epoch 23/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.6971 - accuracy: 0.7547 - val_loss: 1.2726 - val_accuracy: 0.6130\n", - "Epoch 24/30\n", - "782/782 [==============================] - 51s 65ms/step - loss: 0.6785 - accuracy: 0.7612 - val_loss: 1.3208 - val_accuracy: 0.6085\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6991 - accuracy: 0.7528 - val_loss: 1.1290 - val_accuracy: 0.6514\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 17.0 dead neurons (26.56%)!\n", + "Layer conv2d_3 (#5) has 104.0 dead neurons (81.25%)!\n", + "Epoch 24/30\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "782/782 [==============================] - 3s 4ms/step - loss: 0.6802 - accuracy: 0.7620 - val_loss: 1.1516 - val_accuracy: 0.6436\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 99.0 dead neurons (77.34%)!\n", "Epoch 25/30\n", - "782/782 [==============================] - 51s 66ms/step - loss: 0.6611 - accuracy: 0.7683 - val_loss: 1.2839 - val_accuracy: 0.6043\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6835 - accuracy: 0.7589 - val_loss: 1.2096 - val_accuracy: 0.6392\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 21.0 dead neurons (32.81%)!\n", + "Layer conv2d_3 (#5) has 99.0 dead neurons (77.34%)!\n", "Epoch 26/30\n", - "782/782 [==============================] - 49s 63ms/step - loss: 0.6863 - accuracy: 0.7586 - val_loss: 1.3699 - val_accuracy: 0.6050\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6689 - accuracy: 0.7641 - val_loss: 1.1295 - val_accuracy: 0.6481\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 19.0 dead neurons (29.69%)!\n", + "Layer conv2d_3 (#5) has 102.0 dead neurons (79.69%)!\n", "Epoch 27/30\n", - "782/782 [==============================] - 44s 56ms/step - loss: 0.6596 - accuracy: 0.7672 - val_loss: 1.3479 - val_accuracy: 0.5993\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6437 - accuracy: 0.7721 - val_loss: 1.1764 - val_accuracy: 0.6365\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 19.0 dead neurons (29.69%)!\n", + "Layer conv2d_3 (#5) has 100.0 dead neurons (78.12%)!\n", "Epoch 28/30\n", - "782/782 [==============================] - 44s 57ms/step - loss: 0.6706 - accuracy: 0.7638 - val_loss: 1.3462 - val_accuracy: 0.6108\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6597 - accuracy: 0.7688 - val_loss: 1.1849 - val_accuracy: 0.6405\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 25.0 dead neurons (78.12%)!\n", + "Layer conv2d_2 (#3) has 15.0 dead neurons (23.44%)!\n", + "Layer conv2d_3 (#5) has 98.0 dead neurons (76.56%)!\n", "Epoch 29/30\n", - "782/782 [==============================] - 42s 53ms/step - loss: 0.6255 - accuracy: 0.7793 - val_loss: 1.3565 - val_accuracy: 0.6115\n", + "782/782 [==============================] - 3s 4ms/step - loss: 0.6569 - accuracy: 0.7698 - val_loss: 1.1949 - val_accuracy: 0.6350\n", + "Layer conv2d (#0) has 23.0 dead neurons (71.88%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 18.0 dead neurons (28.12%)!\n", + "Layer conv2d_3 (#5) has 104.0 dead neurons (81.25%)!\n", "Epoch 30/30\n", - "782/782 [==============================] - 41s 53ms/step - loss: 0.6392 - accuracy: 0.7762 - val_loss: 1.4635 - val_accuracy: 0.5987\n" + "782/782 [==============================] - 3s 4ms/step - loss: 0.6452 - accuracy: 0.7719 - val_loss: 1.2367 - val_accuracy: 0.6333\n", + "Layer conv2d (#0) has 22.0 dead neurons (68.75%)!\n", + "Layer conv2d_1 (#1) has 24.0 dead neurons (75.00%)!\n", + "Layer conv2d_2 (#3) has 17.0 dead neurons (26.56%)!\n", + "Layer conv2d_3 (#5) has 102.0 dead neurons (79.69%)!\n" ] } ], @@ -447,17 +600,21 @@ " log_frequency=10) # log only every 10 epochs\n", "\n", "# keeps track of the number of dead relus within the network\n", - "relu_callback = DeadReluCallback(sample_images, verbose=True)\n", + "relu_callback = DeadReluCallback(sample_images, \n", + " log_frequency=1, \n", + " verbose=True)\n", "\n", "# creates a GRADCam for the given sample images and the given layer\n", - "cam_callback = GRADCamCallback(sample_images, layer_name='conv2d_3')\n", + "cam_callback = GRADCamCallback(sample_images, \n", + " layer_name='conv2d_3', \n", + " log_frequency=10)\n", "\n", "# train the model with the callbacks\n", "log = model.fit(X_train, Y_train, \n", " epochs=config.epochs, \n", " batch_size=config.batch_size,\n", " validation_data=(X_test, Y_test),\n", - " callbacks=[wandb_callback, act_callback])" + " callbacks=[wandb_callback, act_callback, relu_callback, cam_callback])" ] } ], @@ -477,7 +634,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.6.9" } }, "nbformat": 4, diff --git a/wandb_callbacks/tensorflow.py b/wandb_callbacks/tensorflow.py index d9325ad..6422f03 100644 --- a/wandb_callbacks/tensorflow.py +++ b/wandb_callbacks/tensorflow.py @@ -42,7 +42,7 @@ def on_epoch_end(self, epoch, logs={}): # check if the callback should log or not if (epoch % self.log_frequency) != 0: return - + # Build intermediate layer with the target layer self.intermediate_model = keras.models.Model( inputs=self.model.input, @@ -193,6 +193,10 @@ def on_epoch_end(self, epoch, logs={}): if (epoch % self.log_frequency) != 0: return + # lists to compute final average over all layers + l_dead_neurons = [] + l_percentage_dead = [] + # loop over all relu activations for relu_activation in self.get_relu_activations(): layer_index, activation_values, layer_name, layer_weight_shape = relu_activation @@ -236,10 +240,18 @@ def on_epoch_end(self, epoch, logs={}): # log to wandb percentage_dead_neurons = round(dead_neurons_share * 100, 2) - wandb.log({'n. of dead relus/Layer {} (#{})'.format(layer_name, - layer_index): dead_neurons, - 'percentage dead relus/Layer {} (#{})'.format(layer_name, - layer_index): percentage_dead_neurons}) + wandb.log({'n. of dead relus/Layer {} (#{})'.format(layer_name, layer_index): dead_neurons, + 'percentage dead relus/Layer {} (#{})'.format(layer_name, layer_index): percentage_dead_neurons}) + + # append to overall list + l_dead_neurons.append(dead_neurons) + l_percentage_dead.append(percentage_dead_neurons) + + # log summary of all layers + l_dead_neurons = np.asarray(l_dead_neurons) + l_percentage_dead = np.asarray(l_percentage_dead) + wandb.log({'n. of dead relus/overall mean': l_dead_neurons.mean(), + 'percentage dead relus/overall mean': l_percentage_dead.mean()}) class GRADCamCallback(tf.keras.callbacks.Callback):