{"id":14958804,"url":"https://github.com/chrismattmann/mlwithtensorflow2ed","last_synced_at":"2025-06-22T02:37:17.658Z","repository":{"id":43228545,"uuid":"178787331","full_name":"chrismattmann/MLwithTensorFlow2ed","owner":"chrismattmann","description":"Code for Machine Learning with TensorFlow: 2nd Edition Published by Manning Publications","archived":false,"fork":false,"pushed_at":"2022-11-22T05:48:29.000Z","size":573022,"stargazers_count":139,"open_issues_count":13,"forks_count":69,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-12T14:32:09.839Z","etag":null,"topics":["autoencoder","classification","clustering","deep-learning","docker","machine-learning","machine-learning-algorithms","manning-publications","ml","ml-with-tensorflow","python","python2","regression","tensorflow","tensorflow-tutorials","tika"],"latest_commit_sha":null,"homepage":"http://github.com/chrismattmann/MLwithTensorFlow2ed","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chrismattmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-01T04:47:31.000Z","updated_at":"2025-02-26T03:25:45.000Z","dependencies_parsed_at":"2023-01-22T02:00:38.921Z","dependency_job_id":null,"html_url":"https://github.com/chrismattmann/MLwithTensorFlow2ed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chrismattmann/MLwithTensorFlow2ed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismattmann%2FMLwithTensorFlow2ed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismattmann%2FMLwithTensorFlow2ed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismattmann%2FMLwithTensorFlow2ed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismattmann%2FMLwithTensorFlow2ed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrismattmann","download_url":"https://codeload.github.com/chrismattmann/MLwithTensorFlow2ed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismattmann%2FMLwithTensorFlow2ed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261225741,"owners_count":23127191,"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":["autoencoder","classification","clustering","deep-learning","docker","machine-learning","machine-learning-algorithms","manning-publications","ml","ml-with-tensorflow","python","python2","regression","tensorflow","tensorflow-tutorials","tika"],"created_at":"2024-09-24T13:18:18.890Z","updated_at":"2025-06-22T02:37:12.638Z","avatar_url":"https://github.com/chrismattmann.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"Machine Learning with TensorFlow, 2nd Edition\n=============================================\n\u003ca href=\"https://www.manning.com/books/machine-learning-with-tensorflow-second-edition?a_aid=5700fc87\u0026a_bid=1e05f0bb\" alt=\"Machine Learning with TensorFlow 2nd Edition\"\u003e\u003cimg src=\"figs/mltf2-cover.jpeg\"/\u003e\u003c/a\u003e\n\nThis is the code repository for the 2nd edition of [Manning Publications'](http://manning.com/)\n[Machine Learning with TensorFlow](https://www.manning.com/books/machine-learning-with-tensorflow-second-edition?a_aid=5700fc87\u0026a_bid=1e05f0bb) \nwritten by [Chris Mattmann](http://twitter.com/chrismattmann/).\n\nThe code in this repository is mostly [Jupyter Notebooks](http://jupyter.org/) that correspond\nto the numbered listings in each chapter of the book. The code has beeen tested with \n[TensorFlow 1.15.2](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf) but there \nis a complete porting of the code in the book to [TensorFlow 2.x](https://github.com/chrismattmann/MLwithTensorFlow2ed/tree/master/TFv2).\n\nWe welcome contributions to the TF2 port and to all of the notebooks in TF1.15.x too!\n\n## Quick Start\n\nThe repository contains two fully functional [Docker](https://hub.docker.com/r/chrismattmann/mltf2/tags?page=1\u0026ordering=last_updated) images. The first `latest` runs with TF1.15.x and tracks with the book examples. You can get going by simply running from a command prompt:\n\n```\n$ docker pull chrismattmann/mltf2:latest\n$ ./run_environment.sh\n```\n\nThis will pull the TF1.15.x image and start Juptyer running on localhost. Watch for the startup \nmessage, and then click through (including the token needed past the `?` in the URL) to start\nYour Juptyer session.\n\nTo run the TF2.x version of the code and notebooks you can similarly run the `tf2` tag:\n\n```\n$ docker pull chrismattmann/mltf2:tf2\n$ ./run_TFv2_environment.sh\n``` \n\nFollow the URL from the startup message.\n\nEnjoy!\n\n## Pre-requisites\n\nThough the book has [TensorFlow](http://twitter.com/tensorflow) in the name, the book is also\njust as machine about generalized machine learning and its theory, and the suite of frameworks\nthat also come in handy when dealing with machine learning. The requirements for running the \nnotebooks are below. You should PIP install them using your favorite Python. The examples from\nthe book have been shown to work in Python 2.7, and Python 3.7. I didn't have time to test all \nof them but we are happy to receive PRs for things we've missed.\n\nAdditionally the [Docker](Dockerfile) has been tested and on latest Docker for Mac only adds\nabout 1.5% overhead on CPU mode and is totally usable and a one-shot easy installer for all of\nthe dependencies. Browse the file to see what  you'll need to install and how to run the \ncode locally if desired.\n\n * TensorFlow \n * Jupyter\n * Pandas - for data frames and easy tabular data manipulation\n * NumPy, SciPy\n * Matplotlib\n * [NLTK](http://nltk.org/) - for anything text or NLP (such as Sentiment Analysis from Chapter 6)\n * TQDM - for progress bars\n * SKLearn - for various helper functions\n * [Bregman Toolkit](https://github.com/bregmanstudio/BregmanToolkit/) (for audio examples in Chapter 7)\n * [Tika](http://github.com/chrismattmann/tika-python)\n * [Ystockquote](https://github.com/cgoldberg/ystockquote)\n * Requests\n * [OpenCV](http://opencv.org/)\n * [Horovod](https://github.com/horovod/horovod) - use 0.18.2 (or 0.18.1) for use with the Maverick2 VGG Face model.\n * [VGG16](https://www.cs.toronto.edu/~frossard/post/vgg16/)  - grab `vgg16.py` and `vgg16_weights.npz`, `imagenet_classes.py` and `laska.png` - only works with Python2.7,  place\nin the `lib` directory.\n * PyDub - for Chapter 17 in the LSTM chapter.\n * [Basic Units](https://raw.githubusercontent.com/matplotlib/matplotlib/master/examples/units/basic_units.py) - for use in Chapter 17. Place in `libs/basic_units/` folder.\n * [RNN-Tutorial](https://github.com/mrubash1/RNN-Tutorial/) - used in Chapter 17 to help implement the deep speech model and train it.\n\n## Data Requirements\n\nYou will generate lots of data when running the notebooks in particular building models. But to train and\nbuild those models you will also need data. I have created an easy [DropBox](http://dropbox.com/) folder\nfor you to pull input data for use in training models from the book. Access the DropBox folder \n[here](https://www.dropbox.com/sh/abjqqcwuzx2mttd/AADIM01H44Y-tdAHXUHt5ZWFa?dl=0).\n\nNote that the Docker build described below automatically pulls down all the data for you and incorporates it\ninto the Docker environment so that you don't have to download a thing.\n\nThe pointers below let you know what data you need for what chapters, and where to put it. Unless otherwise\nnot specified, the data should be placed into the `data` folder. Note that as you are running the notebooks\nthe notebooks will generate TF models and write them and `checkpoint` files to the `models/` folder.\n\n## Data Input requirements\n\n### Chapter 4\n - `data/311.csv`\n\n### Chapter 6\n - `data/word2vec-nlp-tutorial/labeledTrainData.tsv`\n - `data/word2vec-nlp-tutorial/testData.tsv`\n - `data/aclImdb/test/neg/`\n - `data/aclImdb/test/pos/`\n\n### Chapter 7\n - `data/audio_dataset/`\n - `data/TalkingMachinesPodcast.wav`\n\n### Chapter 8\n - `data/User Identification From Walking Activity/`\n\n### Chapter 10\n - `data/mobypos.txt`\n\n### Chapter 12\n - `data/cifar-10-batches-py`\n - `data/MNIST_data/` (if you try the MNIST extra example)\n\n### Chapter 14\n - `data/cifar-10-batches-py`\n\n### Chapter 15\n - `data/cifar-10-batches-py`\n - `data/vgg_face_dataset` - The VGG face metadata including Celeb Names\n - `data/vgg-face` - The actual VGG face data\n - `data/vgg_face_full_urls.csv` - Metadata informmation about VGG Face URLs\n - `data/vgg_face_full.csv` - Metadata information about all VGG Face data\n - `data/vgg-models/checkpoints-1e3x4-2e4-09202019` - To run the VGG Face Estimator additional example\n - `models/vgg_face_weights.h5` - To run the VGG Face verification additional example\n\n### Chapter 16\n - `data/international-airline-passengers.csv`\n\n### Chapter 17\n - `data/LibriSpeech`\n - `libs/basic_units/`\n - `libs/RNN-Tutorial/`\n\n### Chapter 18\n - `data/seq2seq`\n\n### Chapter 19\n - `libs/vgg16/laska.png`\n - `data/cloth_folding_rgb_vids`\n\n## Setting up the environment (Tested on Mac and Linux)\n\n### Using Docker\n\n#### Building the image\n\n```shell\n# Only builds a Docker compatible with GPU and CPU.\n./build_environment.sh #TensorFlow1\n./build_TFv2_environment.sh #TensorFlow2\n```\n\n#### Running the notebook from docker\n\n```shell\n# Runs in GPU and CPU mode and will look for NVIDIA drivers first and fall back to reg CPU.\n./run_environment.sh #TensorFlow1\n./run_TFv2_environment.sh # TensorFlow2\n```\n\n#### Using a GPU\n\nYou need to install [nvidia-docker](https://github.com/NVIDIA/nvidia-docker) to use your\nGPU in docker. Follow these instructions (also on the linked page)\n\n```shell\n# Add the package repositories\ndistribution=$(. /etc/os-release;echo $ID$VERSION_ID)\ncurl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -\ncurl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list\n\nsudo apt-get update \u0026\u0026 sudo apt-get install -y nvidia-container-toolkit\nsudo systemctl restart docker\n```\n\n### Using your local python\n\n#### Building the environment\n\nIf you want to build with your existing Python that's fine\nyou  will need a Python2.7 for some of the chapters noted\nabove (like chapter7 which uses `BregmanToolkit`), and\npython 3.7 for everything else. The requirements.txt file\nis different for each, so watch while one to pip install\nbelow.\n\n```shell\n#Python3.7 - GPU and CPU\n$ pip3.7 install -r requirements.txt\n\n#Python3.7 - TensorFlow2 GPU and CPU\n$ pip3.7 install -r requirements-tf2.txt\n\n#Python2.7 - CPU\n$ pip2.7 install -r requirements-py2.txt\n\n#Python2.7 - GPU\n$ pip2.7 install -r requirements-gpu-py2.txt\n```\n\n#### Running the notebook from your local environment\n\n```shell\n$ jupyter notebook\n```\n\nQuestions, comments?\n===================\nSend them to [Chris A. Mattmann](mailto:chris.mattmann@gmail.com).\nAlso please consider heading over to the [livebook forum](https://livebook.manning.com/#!/book/machine-learning-with-tensorflow-second-edition/discussion) where you can discuss the book with other readers and the author too.\n\nContributors\n============\n* Chris A. Mattmann\n* Rob Royce (`tensorflow2` branch)\n* [Philip Southam](https://github.com/philipsoutham) (Dockerfile build in `docker` branch)\n\nLicense\n=======\n[Apache License, version 2](http://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismattmann%2Fmlwithtensorflow2ed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismattmann%2Fmlwithtensorflow2ed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismattmann%2Fmlwithtensorflow2ed/lists"}