TensorFlow Tutorials with YouTube Videos

Overview

TensorFlow Tutorials

Original repository on GitHub

Original author is Magnus Erik Hvass Pedersen

Introduction

  • These tutorials are intended for beginners in Deep Learning and TensorFlow.
  • Each tutorial covers a single topic.
  • The source-code is well-documented.
  • There is a YouTube video for each tutorial.

Tutorials for TensorFlow 2

The following tutorials have been updated and work with TensorFlow 2 (some of them run in "v.1 compatibility mode").

  1. Simple Linear Model (Notebook) (Google Colab)

  2. Convolutional Neural Network (Notebook) (Google Colab)

3-C. Keras API (Notebook) (Google Colab)

  1. Fine-Tuning (Notebook) (Google Colab)

13-B. Visual Analysis for MNIST (Notebook) (Google Colab)

  1. Reinforcement Learning (Notebook) (Google Colab)

  2. Hyper-Parameter Optimization (Notebook) (Google Colab)

  3. Natural Language Processing (Notebook) (Google Colab)

  4. Machine Translation (Notebook) (Google Colab)

  5. Image Captioning (Notebook) (Google Colab)

  6. Time-Series Prediction (Notebook) (Google Colab)

Tutorials for TensorFlow 1

The following tutorials only work with the older TensorFlow 1 API, so you would need to install an older version of TensorFlow to run these. It would take too much time and effort to convert these tutorials to TensorFlow 2.

  1. Pretty Tensor (Notebook) (Google Colab)

3-B. Layers API (Notebook) (Google Colab)

  1. Save & Restore (Notebook) (Google Colab)

  2. Ensemble Learning (Notebook) (Google Colab)

  3. CIFAR-10 (Notebook) (Google Colab)

  4. Inception Model (Notebook) (Google Colab)

  5. Transfer Learning (Notebook) (Google Colab)

  6. Video Data (Notebook) (Google Colab)

  7. Adversarial Examples (Notebook) (Google Colab)

  8. Adversarial Noise for MNIST (Notebook) (Google Colab)

  9. Visual Analysis (Notebook) (Google Colab)

  10. DeepDream (Notebook) (Google Colab)

  11. Style Transfer (Notebook) (Google Colab)

  12. Estimator API (Notebook) (Google Colab)

  13. TFRecords & Dataset API (Notebook) (Google Colab)

Videos

These tutorials are also available as YouTube videos.

Translations

These tutorials have been translated to the following languages:

New Translations

You can help by translating the remaining tutorials or reviewing the ones that have already been translated. You can also help by translating to other languages.

It is a very big job to translate all the tutorials, so you should just start with Tutorials #01, #02 and #03-C which are the most important for beginners.

New Videos

You are also very welcome to record your own YouTube videos in other languages. It is strongly recommended that you get a decent microphone because good sound quality is very important. I used vokoscreen for recording the videos and the free DaVinci Resolve for editing the videos.

Forks

See the selected list of forks for community modifications to these tutorials.

Installation

There are different ways of installing and running TensorFlow. This section describes how I did it for these tutorials. You may want to do it differently and you can search the internet for instructions.

If you are new to using Python and Linux then this may be challenging to get working and you may need to do internet searches for error-messages, etc. It will get easier with practice. You can also run the tutorials without installing anything by using Google Colab, see further below.

Some of the Python Notebooks use source-code located in different files to allow for easy re-use across multiple tutorials. It is therefore recommended that you download the whole repository from GitHub, instead of just downloading the individual Python Notebooks.

Git

The easiest way to download and install these tutorials is by using git from the command-line:

git clone https://github.com/Hvass-Labs/TensorFlow-Tutorials.git

This will create the directory TensorFlow-Tutorials and download all the files to it.

This also makes it easy to update the tutorials, simply by executing this command inside that directory:

git pull

Download Zip-File

You can also download the contents of the GitHub repository as a Zip-file and extract it manually.

Environment

I use Anaconda because it comes with many Python packages already installed and it is easy to work with. After installing Anaconda, you should create a conda environment so you do not destroy your main installation in case you make a mistake somewhere:

conda create --name tf python=3

When Python gets updated to a new version, it takes a while before TensorFlow also uses the new Python version. So if the TensorFlow installation fails, then you may have to specify an older Python version for your new environment, such as:

conda create --name tf python=3.6

Now you can switch to the new environment by running the following (on Linux):

source activate tf

Required Packages

The tutorials require several Python packages to be installed. The packages are listed in requirements.txt

To install the required Python packages and dependencies you first have to activate the conda-environment as described above, and then you run the following command in a terminal:

pip install -r requirements.txt

Starting with TensorFlow 2.1 it includes both the CPU and GPU versions and will automatically switch if you have a GPU. But this requires the installation of various NVIDIA drivers, which is a bit complicated and is not described here.

Python Version 3.5 or Later

These tutorials were developed on Linux using Python 3.5 / 3.6 (the Anaconda distribution) and PyCharm.

There are reports that Python 2.7 gives error messages with these tutorials. Please make sure you are using Python 3.5 or later!

How To Run

If you have followed the above installation instructions, you should now be able to run the tutorials in the Python Notebooks:

cd ~/development/TensorFlow-Tutorials/  # Your installation directory.
jupyter notebook

This should start a web-browser that shows the list of tutorials. Click on a tutorial to load it.

Run in Google Colab

If you do not want to install anything on your own computer, then the Notebooks can be viewed, edited and run entirely on the internet by using Google Colab. There is a YouTube video explaining how to do this. You click the "Google Colab"-link next to each tutorial listed above. You can view the Notebook on Colab but in order to run it you need to login using your Google account. Then you need to execute the following commands at the top of the Notebook, which clones the contents of this repository to your work-directory on Colab.

# Clone the repository from GitHub to Google Colab's temporary drive.
import os
work_dir = "/content/TensorFlow-Tutorials/"
if not os.path.exists(work_dir):
    !git clone https://github.com/Hvass-Labs/TensorFlow-Tutorials.git
os.chdir(work_dir)

All required packages should already be installed on Colab, otherwise you can run the following command:

!pip install -r requirements.txt

Older Versions

Sometimes the source-code has changed from that shown in the YouTube videos. This may be due to bug-fixes, improvements, or because code-sections are moved to separate files for easy re-use.

If you want to see the exact versions of the source-code that were used in the YouTube videos, then you can browse the history of commits to the GitHub repository.

License (MIT)

These tutorials and source-code are published under the MIT License which allows very broad use for both academic and commercial purposes.

A few of the images used for demonstration purposes may be under copyright. These images are included under the "fair usage" laws.

You are very welcome to modify these tutorials and use them in your own projects. Please keep a link to the original repository.

Comments
  • Reinforcement Learning Experiments

    Reinforcement Learning Experiments

    This thread is for documenting your experiments with Reinforcement Learning in Tutorial 16.

    It is also interesting for others to hear if your experiment failed, so they don't have to repeat the same mistakes.

    Please write the following for each of your experiments:

    • English description of the experiment.
    • List the experimental details including the hyper-parameters you have used, how many states and episodes you have trained, etc.
    • What are the test-results (and which epsilon value are you using during testing).
    • Provide a link to your modified code as a Gist on GitHub.
    opened by Hvass-Labs 22
  • About Chinese translation

    About Chinese translation

    The Chinese translation has not been updated for a long time. I have updated the part of tutorials after thrillerist‘s work and willing to update the rest part. Could you recommend my link?(https://github.com/ZhouGeorge/TensorFlow-Tutorials)

    Thank you for your contribution! Hope more people will benefit from your tutorial.

    opened by ZhouGeorge 11
  • import cifar10 gives : ImportError: No module named 'cifar10'

    import cifar10 gives : ImportError: No module named 'cifar10'

    When try to run your CIFAR10 demo code, I get ImportError: No module named 'cifar10' I searched and even tried from tensorflow.image.cifar10 import cifar10 but this fails as well and says : ImportError: No module named 'tensorflow.image' Whats wrong here? is that a typo? Should I be creating my own cifar10? by the way I'm on version 0.10.0 as well

    opened by Coderx7 10
  • In implementing Tutorial 15, there is a URL error for downloading vgg16 model,

    In implementing Tutorial 15, there is a URL error for downloading vgg16 model,

    STOP!

    Most of the problems people are having are already described in the installation instructions.

    Python 3.5

    These tutorials were developed in Python 3.5 and may give strange errors in Python 2.7

    Missing Files

    You need to download the whole repository, either using git clone or as a zip-file. See the installation instructions.

    Questions about TensorFlow

    General questions about TensorFlow should either be asked on StackOverflow or GitHub.

    Suggestions for Changes

    The tutorials cannot change too much because it would make the YouTube videos too different from the source-code.

    Requests for New Tutorials

    These tutorials were made by a single person on his own time. It took a very long time to research and produce the tutorials. If a topic is not covered then the best thing is to make a new tutorial by yourself. All you need is a decent microphone, a screen-grabbing tool, and a video editor. I used the free version of DaVinci Resolve.

    Other Issues?

    Please carefully read the installation instructions and only open an issue if you are still having problems.

    opened by leedqin 9
  • 07_Inception_Model.ipynb give different results ?

    07_Inception_Model.ipynb give different results ?

    I went through this notebook with given introduction. But when I use classify(image_path) function in the notebook it doesn't give correct predictions all the time. If I test it on the given panda image it will first predict correct labels. But if I run in again in will give results like website, web .. etc

    opened by shamanez 7
  • TensorFlow 1.8 doesn't work well with obsolete PrettyTensor

    TensorFlow 1.8 doesn't work well with obsolete PrettyTensor

    I got the following error message from prettytensor

    AttributeError: module 'tensorflow.python.ops.variable_scope' has no attribute '_VARSCOPE_KEY'

    The major cause of this issue is because prettytensor stopped development for a while and tensorflow 1.8 no longer support _VARSCOPE_KEY (Github commit).

    From my own perspective there are two possible actions:

    1. Replace PrettyTensor with Keras To me it is a better solution because it is compatible to future versions of tensorflow. But I guess author has no intention to record the video again
    2. Put tensorflow<1.8 in requirements.txt From a tutorial perspective it works but it is not compatible to future versions of tensorflow
    opened by winstonma 6
  • FailedPreconditionError with Pretty tensor tutorial 3

    FailedPreconditionError with Pretty tensor tutorial 3

    Hi,

    When running your tutorial 3 on pretty tensor, I get FailedPreconditionError. I am using tensorflow_gpu-0.12.0rc0-cp27-none-linux_x86_64 and prettytensor-0.6.2 with python2.7. The error occurs at the first print_test_accuracy() call.

    When I searched on internet, I see that this error can occur if the session variables are not initialized. In your tutorial they are initialized. Moreover I haven't received this error with first two tutorials.

    I am wondering if this has something to do with prettytensor variables. Below is the trace back error message.

    Use `tf.global_variables_initializer` instead.
    Traceback (most recent call last):
      File "train.py", line 139, in <module>
        print_test_accuracy(dataset.data)
      File "train.py", line 88, in print_test_accuracy
        cls_pred[i:j] = session.run(y_pred_cls, feed_dict=feed_dict)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 766, in run
        run_metadata_ptr)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 964, in _run
        feed_dict_string, options, run_metadata)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1014, in _do_run
        target_list, options, run_metadata)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1034, in _do_call
        raise type(e)(node_def, op, message)
    tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value layer_conv1/weights
    	 [[Node: layer_conv1/weights/read = Identity[T=DT_FLOAT, _class=["loc:@layer_conv1/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"](layer_conv1/weights)]]
    
    Caused by op u'layer_conv1/weights/read', defined at:
      File "train.py", line 4, in <module>
        from debug import *
      File "/home/badami/Codes/deeplearning/src/debug.py", line 4, in <module>
        from param import *
      File "/home/badami/Codes/deeplearning/src/param.py", line 14, in <module>
        y_pred, loss = model1(x_image, y_true)
      File "/home/badami/Codes/deeplearning/src/models.py", line 11, in model1
        conv2d(kernel=5, depth=16, name='layer_conv1').\
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1981, in method
        result = func(non_seq_layer, *args, **kwargs)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_image_methods.py", line 159, in __call__
        params = self.variable('weights', size, init, dt=dtype)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/prettytensor/pretty_tensor_class.py", line 1695, in variable
        collections=variable_collections)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1024, in get_variable
        custom_getter=custom_getter)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 850, in get_variable
        custom_getter=custom_getter)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 346, in get_variable
        validate_shape=validate_shape)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 331, in _true_getter
        caching_device=caching_device, validate_shape=validate_shape)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 677, in _get_single_variable
        expected_shape=shape)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 224, in __init__
        expected_shape=expected_shape)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 370, in _init_from_args
        self._snapshot = array_ops.identity(self._variable, name="read")
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1424, in identity
        result = _op_def_lib.apply_op("Identity", input=input, name=name)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
        op_def=op_def)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2240, in create_op
        original_op=self._default_original_op, op_def=op_def)
      File "/home/badami/Codes/deeplearning/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1128, in __init__
        self._traceback = _extract_stack()
    
    FailedPreconditionError (see above for traceback): Attempting to use uninitialized value layer_conv1/weights
    	 [[Node: layer_conv1/weights/read = Identity[T=DT_FLOAT, _class=["loc:@layer_conv1/weights"], _device="/job:localhost/replica:0/task:0/cpu:0"](layer_conv1/weights)]]
    
    opened by ibadami 6
  • ModuleNotFoundError: No module named 'mnist'

    ModuleNotFoundError: No module named 'mnist'

    from mnist import MNIST data = MNIST(data_dir="data/MNIST/")

    ModuleNotFoundError Traceback (most recent call last) in () ----> 1 from mnist import MNIST 2 data = MNIST(data_dir="data/MNIST/")

    ModuleNotFoundError: No module named 'mnist'

    opened by francisalfanta 5
  • Tensor flow   compile error

    Tensor flow compile error

    Hi ,

    I am having the following error in running the CIFAR10 dataset training . Can you give me some where to fix this issue. " File "C:\Users\Prabir Sinha\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1001, in concat ).assert_is_compatible_with(tensor_shape.scalar()) File "C:\Users\Prabir Sinha\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 756, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (2, 1) and () are incompatible "

    Thanks Prabir

    opened by prabirsinha 5
  • CIFAR-10 data import problem

    CIFAR-10 data import problem

    Hi
    I was trying to import CIFAR-10 dataset in my machine but an error raised saying that no module named CIFAR-10. How am i suppose to import CIFAR-10 dataset in python. i am working in python 2.7 environment .

    opened by hexakarthikeyan 5
  • issue when implementing image caption model

    issue when implementing image caption model

    I trained the model, following your instructions. But for some reason, the model produces the same caption for different images. It is as if it is ignoring the initial state supplied to the GRU layer. Can you please help me out

    opened by John-p-v1999 4
  • Missing Files / Modules

    Missing Files / Modules

    Some people are confused about missing files / modules such as mnist.py

    You need to download the entire GitHub repository because some files / modules are used in several tutorials. If you are using Google Colab then you need to clone this repository as well.

    Read the installation instructions for details.

    opened by Hvass-Labs 0
Owner
null
Tensorflow python implementation of "Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos"

Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos This repository is the official tensorflow python implementation

Yasamin Jafarian 287 Jan 6, 2023
A TensorFlow implementation of Neural Program Synthesis from Diverse Demonstration Videos

ViZDoom http://vizdoom.cs.put.edu.pl ViZDoom allows developing AI bots that play Doom using only the visual information (the screen buffer). It is pri

Hyeonwoo Noh 1 Aug 19, 2020
Simple tutorials on Pytorch DDP training

pytorch-distributed-training Distribute Dataparallel (DDP) Training on Pytorch Features Easy to study DDP training You can directly copy this code for

Ren Tianhe 188 Jan 6, 2023
Repository of Jupyter notebook tutorials for teaching the Deep Learning Course at the University of Amsterdam (MSc AI), Fall 2020

Repository of Jupyter notebook tutorials for teaching the Deep Learning Course at the University of Amsterdam (MSc AI), Fall 2020

Phillip Lippe 1.1k Jan 7, 2023
The Incredible PyTorch: a curated list of tutorials, papers, projects, communities and more relating to PyTorch.

This is a curated list of tutorials, projects, libraries, videos, papers, books and anything related to the incredible PyTorch. Feel free to make a pu

Ritchie Ng 9.2k Jan 2, 2023
Pytorch tutorials for Neural Style transfert

PyTorch Tutorials This tutorial is no longer maintained. Please use the official version: https://pytorch.org/tutorials/advanced/neural_style_tutorial

Alexis David Jacq 135 Jun 26, 2022
Pytorch Geometric Tutorials

Pytorch Geometric Tutorials

Antonio Longa 648 Jan 8, 2023
Useful materials and tutorials for 110-1 NTU DBME5028 (Application of Deep Learning in Medical Imaging)

Useful materials and tutorials for 110-1 NTU DBME5028 (Application of Deep Learning in Medical Imaging)

null 7 Jun 22, 2022
Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy.

Deploy tensorflow graphs for fast evaluation and export to tensorflow-less environments running numpy. Now with tensorflow 1.0 support. Evaluation usa

Marcel R. 349 Aug 6, 2022
TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

null 2.6k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Peter Lin 6.5k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting (RVM) English | 中文 Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specific

flow-dev 2 Aug 21, 2022
EasyMocap is an open-source toolbox for markerless human motion capture from RGB videos.

EasyMocap is an open-source toolbox for markerless human motion capture from RGB videos. In this project, we provide the basic code for fitt

ZJU3DV 2.2k Jan 5, 2023
dataset for ECCV 2020 "Motion Capture from Internet Videos"

Motion Capture from Internet Videos Motion Capture from Internet Videos Junting Dong*, Qing Shuai*, Yuanqing Zhang, Xian Liu, Xiaowei Zhou, Hujun Bao

ZJU3DV 98 Dec 7, 2022
This is my codes that can visualize the psnr image in testing videos.

CVPR2018-Baseline-PSNRplot This is my codes that can visualize the psnr image in testing videos. Future Frame Prediction for Anomaly Detection – A New

Wenhao Yang 12 May 29, 2021
Real-world Anomaly Detection in Surveillance Videos- pytorch Re-implementation

Real world Anomaly Detection in Surveillance Videos : Pytorch RE-Implementation This repository is a re-implementation of "Real-world Anomaly Detectio

seominseok 62 Dec 8, 2022
[Open Source]. The improved version of AnimeGAN. Landscape photos/videos to anime

[Open Source]. The improved version of AnimeGAN. Landscape photos/videos to anime

CC 4.4k Dec 27, 2022
Official PyTorch implementation of "IntegralAction: Pose-driven Feature Integration for Robust Human Action Recognition in Videos", CVPRW 2021

IntegralAction: Pose-driven Feature Integration for Robust Human Action Recognition in Videos Introduction This repo is official PyTorch implementatio

Gyeongsik Moon 29 Sep 24, 2022
BMW TechOffice MUNICH 148 Dec 21, 2022