"tensorflow" - TensorFlow Python Library

This section provides a tutorial example on how to install TensorFlow Python library, 'tensorflow'. A very simple TensorFlow application script, hello_tensor.py, is provided.

If you are ready to create your own neural networks with TensorFlow in Python language, you can start with this tutorial to download and install the "tensorflow" Python library.

1. Install TensorFlow Python library, "tensorflow", and required libraries:

herong$ python3 --version
Python 3.8.0

herong$ sudo pip3 install numpy
...
Successfully installed numpy-1.19.0

herong$ sudo pip3 install tensorflow
...
Successfully installed absl-py-0.9.0 astor-0.8.1 gast-0.3.3
  google-pasta-0.2.0 grpcio-1.30.0 h5py-2.10.0 importlib-metadata-1.7.0
  keras-applications-1.0.8 keras-preprocessing-1.1.2 markdown-3.2.2
  setuptools-49.2.0 tensorboard-1.14.0 tensorflow-1.14.0
  tensorflow-estimator-1.14.0 termcolor-1.1.0 werkzeug-1.0.1
  wheel-0.34.2 wrapt-1.12.1 zipp-3.1.0

2. Verify installations:

herong$ python3
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)

>>> import numpy as np
>>> np.1.20
'1.19.0'

>>> import tensorflow as tf
>>> tf.1.20
'1.14.0'

3. Create and run a very simple TensorFlow script, hello_tensor.py:

herong$ type hello_tensor.py
import tensorflow as tf
m = tf.constant(["Hello world!"])
s = tf.Session()
o = s.run(m)
s.close()
print(o)

herong$ python3 hello_tensor.py
/usr/local/lib/python3.6/site-packages/tensorflow/python/framework
  /dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym
  of type is deprecated; in a future version of numpy, it will be
  understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
...

[b'Hello world!']

Okay. "tensorflow" Python library is ready. We can build our own neural networks with TensorFlow now.

If you are getting error on installing "tensorflow" library dependencies, you can try to install it without any dependencies first. Then add them as needed one at a time.

herong$ sudo pip3 install tensorflow --no-deps
Successfully installed tensorflow-1.14.0

Table of Contents

 About This Book

 Deep Playground for Classical Neural Networks

 Building Neural Networks with Python

 Simple Example of Neural Networks

TensorFlow - Machine Learning Platform

 What Is TensorFlow

"tensorflow" - TensorFlow Python Library

 "tensorflow" Interactive Test Web Page

 Tensor and Tensor Flow Graph

 Tensor Operation Properties

 TensorFlow Session Class and run() Function

 TensorFlow Variable Class and load() Function

 Linear Regression with TensorFlow

 tensorflow.examples.tutorials.mnist Module

 Simple TensorFlow Model on MNIST Database

 Commonly Used TensorFlow Funcitons

 PyTorch - Machine Learning Platform

 CNN (Convolutional Neural Network)

 RNN (Recurrent Neural Network)

 GNN (Graph Neural Network)

 References

 Full Version in PDF/EPUB