Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Learning Tensorflow

Table of Contents
Installation......................................................................................................................................................................................................1
Learning Tensorflow

Installation

conda create -n dataweekends pandas scikit-learn jupyter matplotlib

conda activate dataweekends

Install TensorFlow with pip


Available packages
 tensorflow —Current release for CPU-only (recommended for beginners)
 tensorflow-gpu —Current release with GPU support (Ubuntu and Windows)
 tf-nightly —Nightly build for CPU-only (unstable)
 tf-nightly-gpu —Nightly build with GPU support (unstable, Ubuntu and Windows)

System requirements
 Ubuntu 16.04 or later (64-bit)
 macOS 10.12.6 (Sierra) or later (64-bit) (no GPU support)
 Windows 7 or later (64-bit) (Python 3 only)
Learning Tensorflow

 Raspbian 9.0 or later

Hardware requirements
 Starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.
 Read the GPU support guide to set up a CUDA®-enabled GPU card on Ubuntu or Windows.

1. Install the Python development environment on your system

 Python 3  Python 2.7


Check if your Python environment is already configured:

Requires Python 3.4, 3.5, or 3.6


python3 --version
pip3 --version
virtualenv --version

If these packages are already installed, skip to the next step.


Otherwise, install Python, the pip package manager, and Virtualenv:
Learning Tensorflow

UBUNTU

MAC OS

WINDOWS

RASPBERRY PI

OTHER
Install using the Homebrew package manager:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
brew update
brew install python  # Python 3
sudo pip3 install -U virtualenv  # system-wide install

Create a virtual environment (recommended)

Python virtual environments are used to isolate package installation from the system.
Learning Tensorflow

UBUNTU / MAC OS

WINDOWS

CONDA
Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:

virtualenv --system-site-packages -p python3 ./venv

Activate the virtual environment using a shell-specific command:

source ./venv/bin/activate  # sh, bash, ksh, or zsh

When virtualenv is active, your shell prompt is prefixed with (venv).

Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:

pip install --upgrade pip

pip list  # show packages installed within the virtual environment

And to exit virtualenv later:

deactivate  # don't exit until you're done using TensorFlow

Install the TensorFlow pip package

pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl


Learning Tensorflow

To test your installation you can type:

ipython

You can then type:

import keras, tensorflow

to which it should reply: Using TensorFlow backend.

tensorflow.__version__

To stop the ipython console just type CTRL+D twice.


To exit the dataweekends environment, type:
source deactivate

From the terminal

#jupyter notebook

Open a terminal window from the notebook and install tensorflow


Learning Tensorflow

Then you can import tensorflow using the Jupyter.

#import keras, tensorflow


#tensorflow.__version__
Learning Tensorflow

https://databricks.com/tensorflow/interactive-sessions

For each lab perform the following steps:

Activate the environment as follow:


 conda activate dataweekends
 source ./venv/bin/activate  

Start jupyter from that CLIs


Learning Tensorflow

First Tensor Flow

File in jupyter : Learning TensorFlow

Stats to be understand:

simple classifier called softmax regression


stochasticity
cross entropy —a natural choice when the model outputs class probabilities.
gradient descent optimization.

Book: Learning Tensorflow – Oreilly Chapter 2s

You might also like