Tutorial 4

In this tutorial, we are going to train a small Convolutional Neural Network using TensorFlow and convert it to an SNN using the few-spike encoding scheme.

The ANN and converted SNN both achieve around 99% on the MNIST test set.

Install

Download wheel file

[1]:
if "google.colab" in str(get_ipython()):
    !gdown 1V_GzXUDzcFz9QDIpxAD8QNEglcSipssW
    !pip install pygenn-5.0.0-cp310-cp310-linux_x86_64.whl
    %env CUDA_PATH=/usr/local/cuda

    !rm -rf /content/ml_genn
    !git clone https://github.com/genn-team/ml_genn.git --branch genn_5 -c advice.detachedHead=false
    !pip install ./ml_genn/ml_genn
    !pip install ./ml_genn/ml_genn_tf
Downloading...
From: https://drive.google.com/uc?id=1V_GzXUDzcFz9QDIpxAD8QNEglcSipssW
To: /content/pygenn-5.0.0-cp310-cp310-linux_x86_64.whl

0% 0.00/8.29M [00:00<?, ?B/s]

100% 8.29M/8.29M [00:00<00:00, 155MB/s]

Processing ./pygenn-5.0.0-cp310-cp310-linux_x86_64.whl Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.25.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.2.14) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->pygenn==5.0.0) (1.14.1) pygenn is already installed with the same version as the provided wheel. Use –force-reinstall to force an installation of the wheel. env: CUDA_PATH=/usr/local/cuda Cloning into ‘ml_genn’… remote: Enumerating objects: 8253, done. remote: Counting objects: 100% (560/560), done. remote: Compressing objects: 100% (335/335), done. remote: Total 8253 (delta 282), reused 300 (delta 222), pack-reused 7693 Receiving objects: 100% (8253/8253), 37.43 MiB | 20.59 MiB/s, done. Resolving deltas: 100% (5514/5514), done. Processing ./ml_genn/ml_genn

Preparing metadata (setup.py) … done

Requirement already satisfied: pygenn<6.0.0,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (5.0.0) Collecting enum-compat (from ml-genn==2.1.0)

Downloading enum_compat-0.0.3-py3-none-any.whl (1.3 kB)

Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (1.2.14) Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (1.25.2) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->ml-genn==2.1.0) (1.14.1) Building wheels for collected packages: ml-genn

Building wheel for ml-genn (setup.py) … done Created wheel for ml-genn: filename=ml_genn-2.1.0-py3-none-any.whl size=109412 sha256=9431c5dd10d4023c81bef9b2c0c7ba0db404a3963875f88b1b426c2254d970c1 Stored in directory: /tmp/pip-ephem-wheel-cache-f79v7isc/wheels/3f/cf/27/0e9dec4bb1be2afac4b38c2dfb4ce0bc164ce1ecb32b6f91b8

Successfully built ml-genn Installing collected packages: enum-compat, ml-genn Successfully installed enum-compat-0.0.3 ml-genn-2.1.0 Processing ./ml_genn/ml_genn_tf

Preparing metadata (setup.py) … done

Collecting tensorflow<2.15.0 (from ml-genn-tf==2.1.0)
Downloading tensorflow-2.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.9 MB)

<span class=”ansi-black-intense-fg”>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span> <span class=”ansi-green-fg”>489.9/489.9 MB</span> <span class=”ansi-red-fg”>3.4 MB/s</span> eta <span class=”ansi-cyan-fg”>0:00:00</span>

Requirement already satisfied: ml_genn&gt;=2.1.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn-tf==2.1.0) (2.1.0) Requirement already satisfied: pygenn&lt;6.0.0,&gt;=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn&gt;=2.1.0-&gt;ml-genn-tf==2.1.0) (5.0.0) Requirement already satisfied: enum-compat in /usr/local/lib/python3.10/dist-packages (from ml_genn&gt;=2.1.0-&gt;ml-genn-tf==2.1.0) (0.0.3) Requirement already satisfied: tqdm&gt;=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn&gt;=2.1.0-&gt;ml-genn-tf==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml_genn&gt;=2.1.0-&gt;ml-genn-tf==2.1.0) (1.2.14) Requirement already satisfied: absl-py&gt;=1.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.4.0) Requirement already satisfied: astunparse&gt;=1.6.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.6.3) Requirement already satisfied: flatbuffers&gt;=23.5.26 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (24.3.25) Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,&gt;=0.2.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.5.4) Requirement already satisfied: google-pasta&gt;=0.1.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: h5py&gt;=2.9.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.9.0) Requirement already satisfied: libclang&gt;=13.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (18.1.1) Requirement already satisfied: ml-dtypes==0.2.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: numpy&lt;2.0.0,&gt;=1.23.5 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.25.2) Requirement already satisfied: opt-einsum&gt;=2.3.2 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.3.0) Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (24.0) Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,&lt;5.0.0dev,&gt;=3.20.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.20.3) Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (67.7.2) Requirement already satisfied: six&gt;=1.12.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.16.0) Requirement already satisfied: termcolor&gt;=1.1.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2.4.0) Requirement already satisfied: typing-extensions&gt;=3.6.6 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (4.10.0) Requirement already satisfied: wrapt&lt;1.15,&gt;=1.11.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.14.1) Requirement already satisfied: tensorflow-io-gcs-filesystem&gt;=0.23.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.36.0) Requirement already satisfied: grpcio&lt;2.0,&gt;=1.24.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.62.1) Collecting tensorboard&lt;2.15,&gt;=2.14 (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0)

Downloading tensorboard-2.14.1-py3-none-any.whl (5.5 MB)

<span class=”ansi-black-intense-fg”>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span> <span class=”ansi-green-fg”>5.5/5.5 MB</span> <span class=”ansi-red-fg”>3.6 MB/s</span> eta <span class=”ansi-cyan-fg”>0:00:00</span>

Collecting tensorflow-estimator&lt;2.15,&gt;=2.14.0 (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0)
Downloading tensorflow_estimator-2.14.0-py2.py3-none-any.whl (440 kB)

<span class=”ansi-black-intense-fg”>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span> <span class=”ansi-green-fg”>440.7/440.7 kB</span> <span class=”ansi-red-fg”>45.7 MB/s</span> eta <span class=”ansi-cyan-fg”>0:00:00</span>

Collecting keras&lt;2.15,&gt;=2.14.0 (from tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0)
Downloading keras-2.14.0-py3-none-any.whl (1.7 MB)

<span class=”ansi-black-intense-fg”>━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</span> <span class=”ansi-green-fg”>1.7/1.7 MB</span> <span class=”ansi-red-fg”>86.4 MB/s</span> eta <span class=”ansi-cyan-fg”>0:00:00</span>

Requirement already satisfied: wheel&lt;1.0,&gt;=0.23.0 in /usr/local/lib/python3.10/dist-packages (from astunparse&gt;=1.6.0-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.43.0) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn&lt;6.0.0,&gt;=5.0.0-&gt;ml_genn&gt;=2.1.0-&gt;ml-genn-tf==2.1.0) (5.9.5) Requirement already satisfied: google-auth&lt;3,&gt;=1.6.3 in /usr/local/lib/python3.10/dist-packages (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2.27.0) Collecting google-auth-oauthlib&lt;1.1,&gt;=0.5 (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0)

Downloading google_auth_oauthlib-1.0.0-py2.py3-none-any.whl (18 kB)

Requirement already satisfied: markdown&gt;=2.6.8 in /usr/local/lib/python3.10/dist-packages (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: requests&lt;3,&gt;=2.21.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2.31.0) Requirement already satisfied: tensorboard-data-server&lt;0.8.0,&gt;=0.7.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.7.2) Requirement already satisfied: werkzeug&gt;=1.0.1 in /usr/local/lib/python3.10/dist-packages (from tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.0.2) Requirement already satisfied: cachetools&lt;6.0,&gt;=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth&lt;3,&gt;=1.6.3-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (5.3.3) Requirement already satisfied: pyasn1-modules&gt;=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth&lt;3,&gt;=1.6.3-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.4.0) Requirement already satisfied: rsa&lt;5,&gt;=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth&lt;3,&gt;=1.6.3-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (4.9) Requirement already satisfied: requests-oauthlib&gt;=0.7.0 in /usr/local/lib/python3.10/dist-packages (from google-auth-oauthlib&lt;1.1,&gt;=0.5-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (1.3.1) Requirement already satisfied: charset-normalizer&lt;4,&gt;=2 in /usr/local/lib/python3.10/dist-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.3.2) Requirement already satisfied: idna&lt;4,&gt;=2.5 in /usr/local/lib/python3.10/dist-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: urllib3&lt;3,&gt;=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2.0.7) Requirement already satisfied: certifi&gt;=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests&lt;3,&gt;=2.21.0-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2024.2.2) Requirement already satisfied: MarkupSafe&gt;=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug&gt;=1.0.1-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (2.1.5) Requirement already satisfied: pyasn1&lt;0.7.0,&gt;=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules&gt;=0.2.1-&gt;google-auth&lt;3,&gt;=1.6.3-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (0.6.0) Requirement already satisfied: oauthlib&gt;=3.0.0 in /usr/local/lib/python3.10/dist-packages (from requests-oauthlib&gt;=0.7.0-&gt;google-auth-oauthlib&lt;1.1,&gt;=0.5-&gt;tensorboard&lt;2.15,&gt;=2.14-&gt;tensorflow&lt;2.15.0-&gt;ml-genn-tf==2.1.0) (3.2.2) Building wheels for collected packages: ml-genn-tf

Building wheel for ml-genn-tf (setup.py) … done Created wheel for ml-genn-tf: filename=ml_genn_tf-2.1.0-py3-none-any.whl size=11758 sha256=700fc0f37b1b4406839daae478186de651cedf6055410ced0515919e3aa3b1a9 Stored in directory: /tmp/pip-ephem-wheel-cache-1mci3_5m/wheels/ea/96/c7/d55638b75cdda3d23d010a39838aab55dd45fbc104b2fcffc5

Successfully built ml-genn-tf Installing collected packages: tensorflow-estimator, keras, google-auth-oauthlib, tensorboard, tensorflow, ml-genn-tf

Attempting uninstall: tensorflow-estimator

Found existing installation: tensorflow-estimator 2.15.0 Uninstalling tensorflow-estimator-2.15.0:

Successfully uninstalled tensorflow-estimator-2.15.0

Attempting uninstall: keras

Found existing installation: keras 2.15.0 Uninstalling keras-2.15.0:

Successfully uninstalled keras-2.15.0

Attempting uninstall: google-auth-oauthlib

Found existing installation: google-auth-oauthlib 1.2.0 Uninstalling google-auth-oauthlib-1.2.0:

Successfully uninstalled google-auth-oauthlib-1.2.0

Attempting uninstall: tensorboard

Found existing installation: tensorboard 2.15.2 Uninstalling tensorboard-2.15.2:

Successfully uninstalled tensorboard-2.15.2

Attempting uninstall: tensorflow

Found existing installation: tensorflow 2.15.0 Uninstalling tensorflow-2.15.0:

Successfully uninstalled tensorflow-2.15.0

<span class=”ansi-red-fg”>ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tf-keras 2.15.1 requires tensorflow&lt;2.16,&gt;=2.15, but you have tensorflow 2.14.1 which is incompatible.</span><span class=”ansi-red-fg”> </span>Successfully installed google-auth-oauthlib-1.0.0 keras-2.14.0 ml-genn-tf-2.1.0 tensorboard-2.14.1 tensorflow-2.14.1 tensorflow-estimator-2.14.0 </pre>

0% 0.00/8.29M [00:00<?, ?B/s]

100% 8.29M/8.29M [00:00<00:00, 155MB/s]

Processing ./pygenn-5.0.0-cp310-cp310-linux_x86_64.whl Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.25.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.2.14) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->pygenn==5.0.0) (1.14.1) pygenn is already installed with the same version as the provided wheel. Use –force-reinstall to force an installation of the wheel. env: CUDA_PATH=/usr/local/cuda Cloning into ‘ml_genn’{ldots} remote: Enumerating objects: 8253, done. remote: Counting objects: 100% (560/560), done. remote: Compressing objects: 100% (335/335), done. remote: Total 8253 (delta 282), reused 300 (delta 222), pack-reused 7693 Receiving objects: 100% (8253/8253), 37.43 MiB | 20.59 MiB/s, done. Resolving deltas: 100% (5514/5514), done. Processing ./ml_genn/ml_genn

Preparing metadata (setup.py) {ldots} done

Requirement already satisfied: pygenn<6.0.0,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (5.0.0) Collecting enum-compat (from ml-genn==2.1.0)

Downloading enum_compat-0.0.3-py3-none-any.whl (1.3 kB)

Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (1.2.14) Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (1.25.2) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->ml-genn==2.1.0) (1.14.1) Building wheels for collected packages: ml-genn

Building wheel for ml-genn (setup.py) {ldots} done Created wheel for ml-genn: filename=ml_genn-2.1.0-py3-none-any.whl size=109412 sha256=9431c5dd10d4023c81bef9b2c0c7ba0db404a3963875f88b1b426c2254d970c1 Stored in directory: /tmp/pip-ephem-wheel-cache-f79v7isc/wheels/3f/cf/27/0e9dec4bb1be2afac4b38c2dfb4ce0bc164ce1ecb32b6f91b8

Successfully built ml-genn Installing collected packages: enum-compat, ml-genn Successfully installed enum-compat-0.0.3 ml-genn-2.1.0 Processing ./ml_genn/ml_genn_tf

Preparing metadata (setup.py) {ldots} done

Collecting tensorflow<2.15.0 (from ml-genn-tf==2.1.0)
Downloading tensorflow-2.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.9 MB)

textcolor{ansi-black-intense}{━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━} textcolor{ansi-green}{489.9/489.9 MB} textcolor{ansi-red}{3.4 MB/s} eta textcolor{ansi-cyan}{0:00:00}

Requirement already satisfied: ml_genn>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn-tf==2.1.0) (2.1.0) Requirement already satisfied: pygenn<6.0.0,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (5.0.0) Requirement already satisfied: enum-compat in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (0.0.3) Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (1.2.14) Requirement already satisfied: absl-py>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.4.0) Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.6.3) Requirement already satisfied: flatbuffers>=23.5.26 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (24.3.25) Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.5.4) Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: h5py>=2.9.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.9.0) Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (18.1.1) Requirement already satisfied: ml-dtypes==0.2.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: numpy<2.0.0,>=1.23.5 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.25.2) Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.3.0) Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (24.0) Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.20.3) Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (67.7.2) Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.16.0) Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.4.0) Requirement already satisfied: typing-extensions>=3.6.6 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (4.10.0) Requirement already satisfied: wrapt<1.15,>=1.11.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.14.1) Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.36.0) Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.62.1) Collecting tensorboard<2.15,>=2.14 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading tensorboard-2.14.1-py3-none-any.whl (5.5 MB)

textcolor{ansi-black-intense}{━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━} textcolor{ansi-green}{5.5/5.5 MB} textcolor{ansi-red}{3.6 MB/s} eta textcolor{ansi-cyan}{0:00:00}

Collecting tensorflow-estimator<2.15,>=2.14.0 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)
Downloading tensorflow_estimator-2.14.0-py2.py3-none-any.whl (440 kB)

textcolor{ansi-black-intense}{━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━} textcolor{ansi-green}{440.7/440.7 kB} textcolor{ansi-red}{45.7 MB/s} eta textcolor{ansi-cyan}{0:00:00}

Collecting keras<2.15,>=2.14.0 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)
Downloading keras-2.14.0-py3-none-any.whl (1.7 MB)

textcolor{ansi-black-intense}{━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━} textcolor{ansi-green}{1.7/1.7 MB} textcolor{ansi-red}{86.4 MB/s} eta textcolor{ansi-cyan}{0:00:00}

Requirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from astunparse>=1.6.0->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.43.0) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml_genn>=2.1.0->ml-genn-tf==2.1.0) (5.9.5) Requirement already satisfied: google-auth<3,>=1.6.3 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.27.0) Collecting google-auth-oauthlib<1.1,>=0.5 (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading google_auth_oauthlib-1.0.0-py2.py3-none-any.whl (18 kB)

Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.31.0) Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.7.2) Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.0.2) Requirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (5.3.3) Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.4.0) Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (4.9) Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.3.1) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2024.2.2) Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug>=1.0.1->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.1.5) Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.6.0) Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.10/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.2.2) Building wheels for collected packages: ml-genn-tf

Building wheel for ml-genn-tf (setup.py) {ldots} done Created wheel for ml-genn-tf: filename=ml_genn_tf-2.1.0-py3-none-any.whl size=11758 sha256=700fc0f37b1b4406839daae478186de651cedf6055410ced0515919e3aa3b1a9 Stored in directory: /tmp/pip-ephem-wheel-cache-1mci3_5m/wheels/ea/96/c7/d55638b75cdda3d23d010a39838aab55dd45fbc104b2fcffc5

Successfully built ml-genn-tf Installing collected packages: tensorflow-estimator, keras, google-auth-oauthlib, tensorboard, tensorflow, ml-genn-tf

Attempting uninstall: tensorflow-estimator

Found existing installation: tensorflow-estimator 2.15.0 Uninstalling tensorflow-estimator-2.15.0:

Successfully uninstalled tensorflow-estimator-2.15.0

Attempting uninstall: keras

Found existing installation: keras 2.15.0 Uninstalling keras-2.15.0:

Successfully uninstalled keras-2.15.0

Attempting uninstall: google-auth-oauthlib

Found existing installation: google-auth-oauthlib 1.2.0 Uninstalling google-auth-oauthlib-1.2.0:

Successfully uninstalled google-auth-oauthlib-1.2.0

Attempting uninstall: tensorboard

Found existing installation: tensorboard 2.15.2 Uninstalling tensorboard-2.15.2:

Successfully uninstalled tensorboard-2.15.2

Attempting uninstall: tensorflow

Found existing installation: tensorflow 2.15.0 Uninstalling tensorflow-2.15.0:

Successfully uninstalled tensorflow-2.15.0

textcolor{ansi-red}{ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tf-keras 2.15.1 requires tensorflow<2.16,>=2.15, but you have tensorflow 2.14.1 which is incompatible.}textcolor{ansi-red}{ }Successfully installed google-auth-oauthlib-1.0.0 keras-2.14.0 ml-genn-tf-2.1.0 tensorboard-2.14.1 tensorflow-2.14.1 tensorflow-estimator-2.14.0 end{sphinxVerbatim}

0% 0.00/8.29M [00:00<?, ?B/s]

100% 8.29M/8.29M [00:00<00:00, 155MB/s]

Processing ./pygenn-5.0.0-cp310-cp310-linux_x86_64.whl Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.25.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (1.2.14) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn==5.0.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->pygenn==5.0.0) (1.14.1) pygenn is already installed with the same version as the provided wheel. Use –force-reinstall to force an installation of the wheel. env: CUDA_PATH=/usr/local/cuda Cloning into ‘ml_genn’… remote: Enumerating objects: 8253, done. remote: Counting objects: 100% (560/560), done. remote: Compressing objects: 100% (335/335), done. remote: Total 8253 (delta 282), reused 300 (delta 222), pack-reused 7693 Receiving objects: 100% (8253/8253), 37.43 MiB | 20.59 MiB/s, done. Resolving deltas: 100% (5514/5514), done. Processing ./ml_genn/ml_genn

Preparing metadata (setup.py) … [?25l[?25hdone

Requirement already satisfied: pygenn<6.0.0,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (5.0.0) Collecting enum-compat (from ml-genn==2.1.0)

Downloading enum_compat-0.0.3-py3-none-any.whl (1.3 kB)

Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml-genn==2.1.0) (1.2.14) Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (1.25.2) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml-genn==2.1.0) (5.9.5) Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated->ml-genn==2.1.0) (1.14.1) Building wheels for collected packages: ml-genn

Building wheel for ml-genn (setup.py) … [?25l[?25hdone Created wheel for ml-genn: filename=ml_genn-2.1.0-py3-none-any.whl size=109412 sha256=9431c5dd10d4023c81bef9b2c0c7ba0db404a3963875f88b1b426c2254d970c1 Stored in directory: /tmp/pip-ephem-wheel-cache-f79v7isc/wheels/3f/cf/27/0e9dec4bb1be2afac4b38c2dfb4ce0bc164ce1ecb32b6f91b8

Successfully built ml-genn Installing collected packages: enum-compat, ml-genn Successfully installed enum-compat-0.0.3 ml-genn-2.1.0 Processing ./ml_genn/ml_genn_tf

Preparing metadata (setup.py) … [?25l[?25hdone

Collecting tensorflow<2.15.0 (from ml-genn-tf==2.1.0)

Downloading tensorflow-2.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (489.9 MB)

 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 489.9/489.9 MB 3.4 MB/s eta 0:00:00 [?25hRequirement already satisfied: ml_genn>=2.1.0 in /usr/local/lib/python3.10/dist-packages (from ml-genn-tf==2.1.0) (2.1.0) Requirement already satisfied: pygenn<6.0.0,>=5.0.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (5.0.0) Requirement already satisfied: enum-compat in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (0.0.3) Requirement already satisfied: tqdm>=4.27.0 in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (4.66.2) Requirement already satisfied: deprecated in /usr/local/lib/python3.10/dist-packages (from ml_genn>=2.1.0->ml-genn-tf==2.1.0) (1.2.14) Requirement already satisfied: absl-py>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.4.0) Requirement already satisfied: astunparse>=1.6.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.6.3) Requirement already satisfied: flatbuffers>=23.5.26 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (24.3.25) Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.5.4) Requirement already satisfied: google-pasta>=0.1.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: h5py>=2.9.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.9.0) Requirement already satisfied: libclang>=13.0.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (18.1.1) Requirement already satisfied: ml-dtypes==0.2.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.2.0) Requirement already satisfied: numpy<2.0.0,>=1.23.5 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.25.2) Requirement already satisfied: opt-einsum>=2.3.2 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.3.0) Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (24.0) Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.20.3) Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (67.7.2) Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.16.0) Requirement already satisfied: termcolor>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.4.0) Requirement already satisfied: typing-extensions>=3.6.6 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (4.10.0) Requirement already satisfied: wrapt<1.15,>=1.11.0 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.14.1) Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.36.0) Requirement already satisfied: grpcio<2.0,>=1.24.3 in /usr/local/lib/python3.10/dist-packages (from tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.62.1) Collecting tensorboard<2.15,>=2.14 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading tensorboard-2.14.1-py3-none-any.whl (5.5 MB)

 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.5/5.5 MB 3.6 MB/s eta 0:00:00 [?25hCollecting tensorflow-estimator<2.15,>=2.14.0 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading tensorflow_estimator-2.14.0-py2.py3-none-any.whl (440 kB)

 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 440.7/440.7 kB 45.7 MB/s eta 0:00:00 [?25hCollecting keras<2.15,>=2.14.0 (from tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading keras-2.14.0-py3-none-any.whl (1.7 MB)

 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7/1.7 MB 86.4 MB/s eta 0:00:00 [?25hRequirement already satisfied: wheel<1.0,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from astunparse>=1.6.0->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.43.0) Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from pygenn<6.0.0,>=5.0.0->ml_genn>=2.1.0->ml-genn-tf==2.1.0) (5.9.5) Requirement already satisfied: google-auth<3,>=1.6.3 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.27.0) Collecting google-auth-oauthlib<1.1,>=0.5 (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0)

Downloading google_auth_oauthlib-1.0.0-py2.py3-none-any.whl (18 kB)

Requirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: requests<3,>=2.21.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.31.0) Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.7.2) Requirement already satisfied: werkzeug>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.0.2) Requirement already satisfied: cachetools<6.0,>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (5.3.3) Requirement already satisfied: pyasn1-modules>=0.2.1 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.4.0) Requirement already satisfied: rsa<5,>=3.1.4 in /usr/local/lib/python3.10/dist-packages (from google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (4.9) Requirement already satisfied: requests-oauthlib>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (1.3.1) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2.21.0->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2024.2.2) Requirement already satisfied: MarkupSafe>=2.1.1 in /usr/local/lib/python3.10/dist-packages (from werkzeug>=1.0.1->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (2.1.5) Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in /usr/local/lib/python3.10/dist-packages (from pyasn1-modules>=0.2.1->google-auth<3,>=1.6.3->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (0.6.0) Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.10/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<1.1,>=0.5->tensorboard<2.15,>=2.14->tensorflow<2.15.0->ml-genn-tf==2.1.0) (3.2.2) Building wheels for collected packages: ml-genn-tf

Building wheel for ml-genn-tf (setup.py) … [?25l[?25hdone Created wheel for ml-genn-tf: filename=ml_genn_tf-2.1.0-py3-none-any.whl size=11758 sha256=700fc0f37b1b4406839daae478186de651cedf6055410ced0515919e3aa3b1a9 Stored in directory: /tmp/pip-ephem-wheel-cache-1mci3_5m/wheels/ea/96/c7/d55638b75cdda3d23d010a39838aab55dd45fbc104b2fcffc5

Successfully built ml-genn-tf Installing collected packages: tensorflow-estimator, keras, google-auth-oauthlib, tensorboard, tensorflow, ml-genn-tf

Attempting uninstall: tensorflow-estimator

Found existing installation: tensorflow-estimator 2.15.0 Uninstalling tensorflow-estimator-2.15.0:

Successfully uninstalled tensorflow-estimator-2.15.0

Attempting uninstall: keras

Found existing installation: keras 2.15.0 Uninstalling keras-2.15.0:

Successfully uninstalled keras-2.15.0

Attempting uninstall: google-auth-oauthlib

Found existing installation: google-auth-oauthlib 1.2.0 Uninstalling google-auth-oauthlib-1.2.0:

Successfully uninstalled google-auth-oauthlib-1.2.0

Attempting uninstall: tensorboard

Found existing installation: tensorboard 2.15.2 Uninstalling tensorboard-2.15.2:

Successfully uninstalled tensorboard-2.15.2

Attempting uninstall: tensorflow

Found existing installation: tensorflow 2.15.0 Uninstalling tensorflow-2.15.0:

Successfully uninstalled tensorflow-2.15.0

ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. tf-keras 2.15.1 requires tensorflow<2.16,>=2.15, but you have tensorflow 2.14.1 which is incompatible. Successfully installed google-auth-oauthlib-1.0.0 keras-2.14.0 ml-genn-tf-2.1.0 tensorboard-2.14.1 tensorflow-2.14.1 tensorflow-estimator-2.14.0

Train ANN

Firstly we define a simple ANN in Keras with two convolutional layers followed by two dense layers and train it:

[2]:
from tensorflow.keras import models, layers, datasets
from tensorflow.config import experimental

# Irritatingly, TF's default GPU memory allocator  allocates
# all available GPU memory - this can't be freed and would leave
# none for mlGeNN so we turn off this behaviour
for gpu in experimental.list_physical_devices("GPU"):
    experimental.set_memory_growth(gpu, True)

# Load MNIST data and normalise to [0,1]
(train_x, train_y), (test_x, test_y) = datasets.mnist.load_data()
train_x = train_x.reshape((-1, 28, 28, 1)) / 255.0
test_x = test_x.reshape((-1, 28, 28, 1)) / 255.0

# Create and compile TF model
tf_model = models.Sequential([
    layers.Conv2D(16, 5, padding="valid", activation="relu", use_bias=False, input_shape=train_x.shape[1:]),
    layers.AveragePooling2D(2),
    layers.Conv2D(8, 5, padding="valid", activation="relu", use_bias=False),
    layers.AveragePooling2D(2),
    layers.Flatten(),
    layers.Dense(128, activation="relu", use_bias=False),
    layers.Dense(64, activation="relu", use_bias=False),
    layers.Dense(train_y.max() + 1, activation="softmax", use_bias=False),
], name="simple_cnn")
tf_model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])

# Fit TF model
tf_model.fit(train_x, train_y, epochs=10)
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
11490434/11490434 [==============================] - 1s 0us/step
Epoch 1/10
1875/1875 [==============================] - 28s 14ms/step - loss: 0.2250 - accuracy: 0.9315
Epoch 2/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0792 - accuracy: 0.9754
Epoch 3/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0576 - accuracy: 0.9826
Epoch 4/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0459 - accuracy: 0.9855
Epoch 5/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0374 - accuracy: 0.9883
Epoch 6/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0310 - accuracy: 0.9898
Epoch 7/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0275 - accuracy: 0.9910
Epoch 8/10
1875/1875 [==============================] - 22s 12ms/step - loss: 0.0232 - accuracy: 0.9926
Epoch 9/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0212 - accuracy: 0.9932
Epoch 10/10
1875/1875 [==============================] - 23s 12ms/step - loss: 0.0188 - accuracy: 0.9940
[2]:
<keras.src.callbacks.History at 0x7a30831d9960>

Evaluate ANN model

Now we evaluate the ANN on the MNIST test set:

[3]:
tf_model.evaluate(test_x, test_y)
313/313 [==============================] - 2s 4ms/step - loss: 0.0354 - accuracy: 0.9897
[3]:
[0.03539454564452171, 0.9897000193595886]

Build normalization dataset

To correctly configure the conversion algorithm, the range of activations in each layer is required. We determine this from a single, randomly selected batch of training data. Slightly awkwardly, mlGeNN takes these as an iterator so we turn them into a TF dataset:

[4]:
import numpy as np
from tensorflow.data import Dataset, AUTOTUNE

# ML GeNN norm dataset
norm_i = np.random.choice(train_x.shape[0], 128, replace=False)

norm_ds = Dataset.from_tensor_slices((train_x[norm_i], train_y[norm_i]))
norm_ds = norm_ds.batch(128)
norm_ds = norm_ds.prefetch(AUTOTUNE)

Convert model

We are going to use the few-spike conversion scheme to convert the ANN to an SNN with \(k=8\) timesteps per examples:

Stöckl, Christoph, and Wolfgang Maass. 2021. “Optimized Spiking Neurons Can Classify Images with High Accuracy through Temporal Coding with Two Spikes.” Nature Machine Intelligence 3(3): 230–38 (doi)

[5]:
from ml_genn_tf.converters import FewSpike

# Build few-spike converter
converter = FewSpike(k=8, norm_data=[norm_ds])

# Convert and compile ML GeNN model
net, net_inputs, net_outputs, tf_layer_pops = converter.convert(tf_model)

Compilation

In mlGeNN, in order to turn an abstract network description into something that can actually be used for training or inference you use a compiler class. Here, we ask the converter to build us a suitable compiler and specify batch size and that we don’t want connectvity expanded into sparse connectivity.

[6]:
compiler = converter.create_compiler(prefer_in_memory_connect=False, batch_size=128)
compiled_net = compiler.compile(net, inputs=net_inputs, outputs=net_outputs)

Evaluate SNN models

Finally, we evaluate the SNN model on the MNIST test set:

[7]:
with compiled_net:
    compiled_net.evaluate({net_inputs[0]: test_x},
                          {net_outputs[0]: test_y})