How to install tensorflow and keras on windows10

I am going to explain how to install tensorflow and keras on windows10.

 

This article is originally written by Japanese, and translated into English because I must practice writing English sentence.

 

Please employ this installation at your responsibility.

 

I installed the latest versions of tensorflow and keras on 24 May, 2018.

The enviroment is as shown below:

windows 10 64bit

python 3.6 (installed with anaconda)

tensorflow 1.8.0 (cpu version)

keras 2.1.5

 

(1) Install anaconda

Let me skip how to install anaconda because there are many articles about that.

 

(2) Install tensorflow

(2-1) Download win-64/tensorflow-1.8.0-py36_1.tar.bz2 from here.

 

(2-2) Move to the directry where the downloded file is, and install by the following command.

conda install tensorflow-1.8.0-py36_1.tar.bz2

 

(2-3) Invoke python interpreter, and import tensorflow by the following command.

import tensorflow as tf

 

Probably, you will be said that there is no module named "google".

 

(3) Install protobuf

Honestly, I do not know protobuf well. 

As far as I know, protobuf stands for protocol buffer, and it seems that its role is to make .py file from .proto file.

ex.)protobuf test.proto → test.py

(ref) Protocol Buffers 入門

 

(3-1) Download win-64/protobuf-3.5.2-py36h6538335_0.tar.bz2 from here.

 

(3-2) Execute the following command where the downloaded file is.

conda install protobuf-3.5.2-py36h6538335_0.tar.bz2

 

(3-3) Invoke python interpreter, and import tensorflow by the following command.

import tensorflow as tf

 

Probably, you will be said that there is no module named "absl".

 

(4) Install absl

Honestly, I do not know absl well. 

As far as I know, absl stands for Abseil, and important libraries that Google uses.

(ref) abseil / Welcome to Abseil!

 

(4-1) Download win-64/absl-py-0.2.1-py36_0.tar.bz2 from here.

 

(4-2) Execute the following command where the downloaded file is.

conda install absl-py-0.2.1-py36_0.tar.bz2

 

(4-3) Invoke python interpreter, and import tensorflow by the following command.

import tensorflow as tf

 

In my case, I succeeded to install tensorflow by the above procedure.

  

(5) Install keras

(5-1) Download win-64/keras-2.1.5-py36_0.tar.bz2 from here.

 

(5-2) Execute the following command where the downloaded file is.

conda install keras-2.1.5-py36_0.tar.bz2

 

(5-3) Invoke python interpreter, and import tensorflow and keras by the following commands.

import tensorflow as tf

import keras

 

Probably the following message is return.

Using theano backend 

And you will be said that there is no module named "theano".

 

(5-4) To chage the backend from theano to tensorflow,

you need to rewrite ~/anaconda3/etc/activated.d/keras_activated.dat.

Specifically, you chage the contents from

set "KERAS_BACKEND=theans"

to

set "KERAS_BACKEND=tensorflow"

 

(ref) KerasのバックエンドがTheanoから変更できなくなった話 - 粗大メモ置き場

 

Related articles

haitenaipants.hatenablog.com

 

haitenaipants.hatenablog.com