【深層学習】 TensorFlow と Keras をインストールする【Python】
公開日:
:
最終更新日:2020/05/21
機械学習 DeepLearning, Keras, python, TensorFlow, インストール, 深層学習
今回は、Google Colaboratory 上で、深層学習(DeepLearning)フレームワークである TensorFlow と、深層学習フレームワークをバックエンドエンジンとして使う Keras をインストールする方法を紹介します。
Contents
Keras とは?
Keras は、複数の深層学習フレームワーク(TensorFlow、Theano、CNTK、など)をバックエンドで使用できる Python のライブラリのことです。
複数の深層学習フレームワーク(TensorFlow、Theano、CNTK、など)を共通の言語で使えるというイメージです。
TensorFlow とは?
TensorFlow は、Google によって開発された機械学習・深層学習フレームワークです。
2020 年現在最も人気のある機械学習・深層学習フレームワークです。
インストール手順
Google Colaboratory 上に Keras と TensorFlow をインストールします。
Google Colaboratory を使う理由は、GPU 環境が無料で使えるからです。
Google Colaboratory については、以前まとめました。
【Google Colaboratory】クラウド上でPythonを使って機械学習を行う。
Python のバージョンは Python 3 を使用します。
TensorFlowのインストール
以下のコマンドを実行します。
Google Colaboratory 環境なので先頭に「!」記号を付けます。
1 |
!pip install tensorflow |
以下のように出力されます。
Requirement already satisfied: tensorflow in /usr/local/lib/python3.6/dist-packages (2.2.0)
Requirement already satisfied: absl-py>=0.7.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.9.0)
Requirement already satisfied: gast==0.3.3 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (0.3.3)
Requirement already satisfied: h5py<2.11.0,>=2.10.0 in /usr/local/lib/python3.6/dist-packages (from tensorflow) (2.10.0)
以下省略
以下のコマンドで TensorFlow のバージョン確認を行います。
1 2 |
import tensorflow as tf print(tf.__version__) |
バージョン情報が表示されます。
2.2.0
Keras のインストール
以下のコマンドを実行します。
1 |
!pip install keras |
Requirement already satisfied: keras in /usr/local/lib/python3.6/dist-packages (2.3.1)
Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras) (1.18.4)
Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from keras) (1.0.8)
Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras) (2.10.0)
Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from keras) (1.12.0)
Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras) (1.4.1)
Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from keras) (1.1.2)
Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from keras) (3.13)
以下のコマンドで Keras のバージョン確認を行います。
1 2 |
import keras print(keras.__version__) |
バージョン情報と、バックエンドで TensorFlow が使われていることが確認できます。
2.3.1
Using TensorFlow backend.
関連記事
-
-
【転移学習】学習済みVGG16 による転移学習を行う方法【PyTorch】
今回は、PyTorch を使って、学習済みのモデル VGG16 を用いて転移学習をしてみました。
-
-
【Weka】CSVファイルを読み込んで決定木を実行。
フリーの機械学習ソフト Weka を使って、CSVファイルを読み込んで決定木(Decision Tr
-
-
【機械学習】モンテカルロ法(Monte Carlo method)について。
モンテカルロ法(Monte Carlo method)とは、シュミレーションや数値計算を乱数を用いて
-
-
【機械学習】 scikit-learn で不正解データを抽出する方法【Python】
Python の scikit-learn ライブラリを使って機械学習でテストデータを識別(2クラス
-
-
【画像認識】 Google画像検索結果を取得する方法 【google image download】
今回は、深層学習(DeepLearning)で画像認識をするための画像データの収集を、Google画
-
-
【Weka】欠損データを自動的に補完するフィルタを使ってみた。
機械学習で用いるデータについてです。データは完璧なことに越したことはないが、通常は、ある属性の値が入
-
-
【探索】ダイクストラ法・最良優先探索・Aアルゴリズムの比較。
縦型探索や横型探索では、機械的に順序を付け、最小ステップでゴールを目指します。 つまり、
-
-
【Chainer】手書き数字認識をしてみた【Deep Learning】
Chainerを用いて、ニューラルネットワークを構築し、手書き数字認識を行ったときのメモです。
-
-
【TensorFlow】GPUを認識しない時の対処方法【Python】
TensorFlow で GPU を認識させようとしたときにハマってしまったので、その対処方法のメモ
-
-
【機械学習】 scikit-learn で精度・再現率・F値を算出する方法【Python】
今回は、2クラス分類で Python の scikit-learn を使った評価指標である、精度(P