[PYTHON] [Note] Regarding Tensorflow

Introduction

I would like to summarize what I found by using Tensorflow (Keras) so far.

1. Installation of Tensorflow in a virtual environment

When installing Tensorflow in a virtual environment, it can be divided into cases where Anaconda's conda instruction and Python's pip instruction are used. Each feature is organized in the table below.

item conda pip
Installation command conda install -c anaconda tensorflow-gpu pip install --upgrade tensorflow
merit CUDA,cuDNN is also installed automatically. Super convenient! 2020.As of 09 Tensorflow 2.3
pip install -r requirement.txt is very convenient
Demerit 2020.As of 09 Tensorflow 2.1 is the latest version.
tensorflow-estimator Verison is 2.There is a case where it is 3.[2]At that time, conda install tensorflow-estimator==2.1.At 0, tensorflow-estimator version 2.1 manually installed
CUDA,You need to install CuDNN yourself.
It is said that the performance of Tensorflow with pip is worse than that with conda.[1]
  1. Tensorflow 2.0 with Keras There were a number of changes when it came to Tensorflow 2.0.
item Tensorflow 1.X Tensorflow 2.X
Installation TensorflowとKerasを別々Installation TensorflowだけInstallation
import part import tensorflow as tf
import keras
import tensorflow as tf 
import tf.keras

3. How to change the version of Tensorflow in Google Colab

As of September 2020, the version of Tensorflow on Google Colab is 2.3. But let's say the version of Tensorflow on your local machine is 2.1. At that time, you need to change the version of Tensorflow of Google Colab from 2.3 to 2.1.

#Enter into Google Colab
#Downgrade tensorflow

!pip install tensorflow-gpu==2.1
import tensorflow as tf
print(tf.__version__)

4. Reference materials

  1. Stop Installing Tensorflow using pip for performance sake!
  2. AttributeError: module 'tensorflow' has no attribute 'compat'

Recommended Posts

[Note] Regarding Tensorflow
Note
Note
Note
A note about TensorFlow Introduction
Django note 4
pyenv note
GroupBy Note
argparse note
Django Note 5
Note: Python
Regarding transformer
Ansible Note
Python note
Tensorflow Glossary
tensorflow mnist_deep.py
Regarding Pyston 0.3
Django Note 1
direnv note
Django note 3
TensorFlow tutorial tutorial
Django note 2
[Note] RepresenterError