{"id":13935121,"url":"https://github.com/leriomaggio/deep-learning-keras-tensorflow","last_synced_at":"2025-05-14T21:10:31.423Z","repository":{"id":41523127,"uuid":"64746852","full_name":"leriomaggio/deep-learning-keras-tensorflow","owner":"leriomaggio","description":"Introduction to Deep Neural Networks with Keras and Tensorflow","archived":false,"fork":false,"pushed_at":"2023-07-25T14:37:43.000Z","size":62715,"stargazers_count":2957,"open_issues_count":13,"forks_count":1273,"subscribers_count":198,"default_branch":"master","last_synced_at":"2025-04-06T13:08:05.873Z","etag":null,"topics":["anaconda","cudnn","deep-learning","keras","keras-tensorflow","keras-tutorials","python","tensorflow","theano","tutorial"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leriomaggio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-02T10:13:21.000Z","updated_at":"2025-04-01T21:49:02.000Z","dependencies_parsed_at":"2024-09-24T13:38:31.994Z","dependency_job_id":null,"html_url":"https://github.com/leriomaggio/deep-learning-keras-tensorflow","commit_stats":{"total_commits":121,"total_committers":9,"mean_commits":"13.444444444444445","dds":"0.30578512396694213","last_synced_commit":"b996ea1faba3ee7d01ea7bd733d2e7cd71be6bb5"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leriomaggio%2Fdeep-learning-keras-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leriomaggio%2Fdeep-learning-keras-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leriomaggio%2Fdeep-learning-keras-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leriomaggio%2Fdeep-learning-keras-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leriomaggio","download_url":"https://codeload.github.com/leriomaggio/deep-learning-keras-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741201,"owners_count":21154255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anaconda","cudnn","deep-learning","keras","keras-tensorflow","keras-tutorials","python","tensorflow","theano","tutorial"],"created_at":"2024-08-07T23:01:24.452Z","updated_at":"2025-04-13T16:10:32.003Z","avatar_url":"https://github.com/leriomaggio.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"\u003cdiv\u003e\r\n    \u003ch1 style=\"text-align: center;\"\u003eDeep Learning with Keras and Tensorflow\u003c/h1\u003e\r\n    \u003cimg style=\"text-align: left\" src=\"https://blog.keras.io/img/keras-tensorflow-logo.jpg\" width=\"15%\" /\u003e\r\n\u003cdiv\u003e\r\n\u003cbr\u003e\r\n\r\n### Author: Valerio Maggio\r\n\r\n#### Contacts:\r\n\r\n\u003ctable style=\"border: 0px; display: inline-table\"\u003e\r\n    \u003ctbody\u003e\r\n        \u003ctr style=\"border: 0px;\"\u003e\r\n            \u003ctd style=\"border: 0px;\"\u003e\r\n                \u003cimg src=\"imgs/twitter_small.png\" style=\"display: inline-block;\" /\u003e \r\n                \u003ca href=\"http://twitter.com/leriomaggio\" target=\"_blank\"\u003e@leriomaggio\u003c/a\u003e\r\n\t    \u003c/td\u003e\r\n            \u003ctd style=\"border: 0px;\"\u003e\r\n                \u003cimg src=\"imgs/linkedin_small.png\" style=\"display: inline-block;\" /\u003e \r\n                \u003ca href=\"it.linkedin.com/in/valeriomaggio\" target=\"_blank\"\u003evaleriomaggio\u003c/a\u003e\r\n            \u003c/td\u003e\r\n            \u003ctd style=\"border: 0px;\"\u003e\r\n                \u003cimg src=\"imgs/gmail_small.png\" style=\"display: inline-block;\" /\u003e \r\n                valeriomaggio_at_gmail\r\n            \u003c/td\u003e\r\n       \u003c/tr\u003e\r\n  \u003c/tbody\u003e\r\n\u003c/table\u003e\r\n\r\n\r\n```shell\r\n\r\ngit clone https://github.com/leriomaggio/deep-learning-keras-tensorflow.git\r\n```\r\n\r\n---\r\n\r\n## Table of Contents\r\n\r\n- **Part I**: **Introduction**\r\n\r\n    - Intro to Artificial Neural Networks\r\n        - Perceptron and MLP    \r\n        - naive pure-Python implementation\r\n        - fast forward, sgd, backprop\r\n        \r\n    - Introduction to Deep Learning Frameworks\r\n        - Intro to Theano\r\n        - Intro to Tensorflow\r\n        - Intro to Keras\r\n            - Overview and main features\r\n            - Overview of the `core` layers\r\n            - Multi-Layer Perceptron and Fully Connected\r\n                - Examples with `keras.models.Sequential` and `Dense`\r\n            - Keras Backend\r\n    \r\n- **Part II**: **Supervised Learning**\r\n    \r\n    - Fully Connected Networks and Embeddings\r\n        - Intro to MNIST Dataset\r\n        - Hidden Leayer Representation and Embeddings\r\n        \r\n    - Convolutional Neural Networks\r\n        - meaning of convolutional filters\r\n            - examples from ImageNet    \r\n        - Visualising ConvNets \r\n\r\n        - Advanced CNN\r\n            - Dropout\r\n            - MaxPooling\r\n            - Batch Normalisation\r\n\r\n        - HandsOn: MNIST Dataset\r\n            - FC and MNIST\r\n            - CNN and MNIST\r\n        \r\n        - Deep Convolutional Neural Networks with Keras (ref: `keras.applications`)\r\n            - VGG16\r\n            - VGG19\r\n            - ResNet50\r\n    - Transfer Learning and FineTuning\r\n    - Hyperparameters Optimisation \r\n        \r\n- **Part III**: **Unsupervised Learning**\r\n\r\n    - AutoEncoders and Embeddings\r\n\t- AutoEncoders and MNIST\r\n    \t- word2vec and doc2vec (gensim) with `keras.datasets`\r\n        - word2vec and CNN\r\n    \r\n- **Part IV**: **Recurrent Neural Networks**\r\n    - Recurrent Neural Network in Keras \r\n        -  `SimpleRNN`, `LSTM`, `GRU`\r\n    - LSTM for Sentence Generation\r\n\t\t\r\n- **PartV**: **Additional Materials**:  \r\n   - Custom Layers in Keras \r\n   - Multi modal Network Topologies with Keras\r\n\r\n---\r\n\r\n# Requirements\r\n\r\nThis tutorial requires the following packages:\r\n\r\n- Python version 3.5\r\n    - Python 3.4 should be fine as well\r\n    - likely Python 2.7 would be also fine, but *who knows*? :P\r\n    \r\n- `numpy` version 1.10 or later: http://www.numpy.org/\r\n- `scipy` version 0.16 or later: http://www.scipy.org/\r\n- `matplotlib` version 1.4 or later: http://matplotlib.org/\r\n- `pandas` version 0.16 or later: http://pandas.pydata.org\r\n- `scikit-learn` version 0.15 or later: http://scikit-learn.org\r\n- `keras` version 2.0 or later: http://keras.io\r\n- `tensorflow` version 1.0 or later: https://www.tensorflow.org\r\n- `ipython`/`jupyter` version 4.0 or later, with notebook support\r\n\r\n(Optional but recommended):\r\n\r\n- `pyyaml`\r\n- `hdf5` and `h5py` (required if you use model saving/loading functions in keras)\r\n- **NVIDIA cuDNN** if you have NVIDIA GPUs on your machines.\r\n    [https://developer.nvidia.com/rdp/cudnn-download]()\r\n\r\nThe easiest way to get (most) these is to use an all-in-one installer such as [Anaconda](http://www.continuum.io/downloads) from Continuum. These are available for multiple architectures.\r\n\r\n---\r\n\r\n### Python Version\r\n\r\nI'm currently running this tutorial with **Python 3** on **Anaconda**\r\n\r\n\r\n```python\r\n!python --version\r\n```\r\n\r\n    Python 3.5.2\r\n\r\n---\t\r\n\t\r\n## Setting the Environment\r\n\r\nIn this repository, files to re-create virtual env with `conda` are provided for Linux and OSX systems, \r\nnamely `deep-learning.yml` and `deep-learning-osx.yml`, respectively.\r\n\r\nTo re-create the virtual environments (on Linux, for example):\r\n\r\n```shell\r\nconda env create -f deep-learning.yml\r\n```\r\n\r\nFor OSX, just change the filename, accordingly.\r\n\r\n### Notes about Installing Theano with GPU support\r\n\r\n**NOTE**: Read this section **only** if after _pip installing_ `theano`, it raises error in enabling the GPU support!\r\n\r\nSince version `0.9` Theano introduced the [`libgpuarray`](http://deeplearning.net/software/libgpuarray) in the stable release (it was previously only available in the _development_ version).\r\n\r\nThe goal of `libgpuarray` is (_from the documentation_) make a common GPU ndarray (n dimensions array) that can be reused by all projects that is as future proof as possible, while keeping it easy to use for simple need/quick test.\r\n\r\nHere are some useful tips (hopefully) I came up with to properly install and configure `theano` on (Ubuntu) Linux with **GPU** support:\r\n\r\n1) [If you're using Anaconda] `conda install theano pygpu` should be just fine!\r\n\r\nSometimes it is suggested to install `pygpu` using the `conda-forge` channel:\r\n\r\n`conda install -c conda-forge pygpu`\r\n\r\n2) [Works with both Anaconda Python or Official CPython]\r\n\r\n* Install `libgpuarray` from source: [Step-by-step install libgpuarray user library](http://deeplearning.net/software/libgpuarray/installation.html#step-by-step-install-user-library)\r\n\r\n* Then, install `pygpu` from source: (in the same source folder)\r\n`python setup.py build \u0026\u0026 python setup.py install`\r\n\r\n* `pip install theano`.\r\n\r\n\r\nAfter **Theano is installed**:\r\n\r\n```\r\necho \"[global]\r\ndevice = cuda\r\nfloatX = float32\r\n\r\n[lib]\r\ncnmem = 1.0\" \u003e ~/.theanorc\r\n```\r\n\r\n### Installing Tensorflow\r\n\r\nTo date `tensorflow` comes in two different packages, namely `tensorflow` and `tensorflow-gpu`, whether you want to install \r\nthe framework with CPU-only or GPU support, respectively.\r\n\r\nFor this reason, `tensorflow` has **not** been included in the conda envs and has to be installed separately.\r\n\r\n#### Tensorflow for CPU only:\r\n\r\n```shell\r\npip install tensorflow\r\n```\r\n\r\n#### Tensorflow with GPU support:\r\n\r\n```shell\r\npip install tensorflow-gpu\r\n```\r\n\r\n**Note**: NVIDIA Drivers and CuDNN **must** be installed and configured before hand. Please refer to the official \r\n[Tensorflow documentation](https://www.tensorflow.org/install/) for further details.\r\n\r\n\r\n#### Important Note:\r\n\r\nAll the code provided+ in this tutorial can run even if `tensorflow` is **not** installed, and so using `theano` as the (default) backend!\r\n\r\n___**This** is exactly the power of Keras!___\r\n\r\nTherefore, installing `tensorflow` is **not** stricly required!\r\n\r\n+: Apart from the **1.2 Introduction to Tensorflow** tutorial, of course.\r\n\r\n### Configure Keras with tensorflow\r\n\r\nBy default, Keras is configured with `theano` as backend. \r\n\r\nIf you want to use `tensorflow` instead, these are the simple steps to follow:\r\n\r\n1) Create the `keras.json` (if it does not exist):\r\n\r\n```shell\r\ntouch $HOME/.keras/keras.json\r\n```\r\n\r\n2) Copy the following content into the file:\r\n\r\n```\r\n{\r\n    \"epsilon\": 1e-07,\r\n    \"backend\": \"tensorflow\",\r\n    \"floatx\": \"float32\",\r\n    \"image_data_format\": \"channels_last\"\r\n}\r\n```\r\n\r\n3) Verify it is properly configured:\r\n\r\n```python\r\n!cat ~/.keras/keras.json\r\n```\r\n\r\n    {\r\n    \t\"epsilon\": 1e-07,\r\n    \t\"backend\": \"tensorflow\",\r\n    \t\"floatx\": \"float32\",\r\n    \t\"image_data_format\": \"channels_last\"\r\n    }\r\n\r\n---\r\n\r\n# Test if everything is up\u0026running\r\n\r\n## 1. Check import\r\n\r\n\r\n```python\r\nimport numpy as np\r\nimport scipy as sp\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\nimport sklearn\r\n```\r\n\r\n\r\n```python\r\nimport keras\r\n```\r\n\r\n    Using TensorFlow backend.\r\n\r\n\r\n## 2. Check installed Versions\r\n\r\n\r\n```python\r\nimport numpy\r\nprint('numpy:', numpy.__version__)\r\n\r\nimport scipy\r\nprint('scipy:', scipy.__version__)\r\n\r\nimport matplotlib\r\nprint('matplotlib:', matplotlib.__version__)\r\n\r\nimport IPython\r\nprint('iPython:', IPython.__version__)\r\n\r\nimport sklearn\r\nprint('scikit-learn:', sklearn.__version__)\r\n```\r\n\r\n    numpy: 1.11.1\r\n    scipy: 0.18.0\r\n    matplotlib: 1.5.2\r\n    iPython: 5.1.0\r\n    scikit-learn: 0.18\r\n\r\n\r\n\r\n```python\r\nimport keras\r\nprint('keras: ', keras.__version__)\r\n\r\n# optional\r\nimport theano\r\nprint('Theano: ', theano.__version__)\r\n\r\nimport tensorflow as tf\r\nprint('Tensorflow: ', tf.__version__)\r\n```\r\n\r\n    keras:  2.0.2\r\n    Theano:  0.9.0\r\n    Tensorflow:  1.0.1\r\n\r\n\r\n\u003cbr\u003e\r\n\u003ch1 style=\"text-align: center;\"\u003eIf everything worked till down here, you're ready to start!\u003c/h1\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleriomaggio%2Fdeep-learning-keras-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleriomaggio%2Fdeep-learning-keras-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleriomaggio%2Fdeep-learning-keras-tensorflow/lists"}