Install Theano as backend in Ubuntu Keras

Source: Internet
Author: User
Tags json theano keras

Reference: Keras Chinese Handbook

Note: This installation has only a CPU-accelerated process and no GPU acceleration. 1. First install Linux recommended Ubuntu, version can choose 16.04. 2. Ubuntu Initial environment Settings (1) First system upgrade

>>>sudo APT Update

>>>sudo apt Upgrade (2) to install a Python-based development package

>>>sudo apt install-y python-dev python-pip python-nose gcc g++ git gfortran vim 3. Install Operation Acceleration Library

>>>sudo apt install-y libopenblas-dev liblapack-dev libatlas-base-dev 4.keras Frame construction

>>>sudo pip install-u--pre pip setuptools Wheel

>>>sudo pip install-u--pre numpy scipy matplotlib scikit-learn scikit-image

>>>sudo pip Install-u--pre Theano

>>>sudo pip install-u--pre keras 5. After the installation is successful, start the test

>>>python//Enter the Python environment

>>>import Theano

>>>import Keras

It should be explained here that, since Keras default backend is TensorFlow, an error occurs when you execute import keras, as shown in the following figure.


So we need to rewrite Keras.json This configuration document, modify the Keras default backend to Theano. This document is in: ~/.keras/keras.json, some people who are unfamiliar with Linux will not understand the meaning of this path, ~ represents your/home/user name directory,. Keras's front '. ' Represents a hidden file. Therefore, this file does not exist in the Keras installation directory, this should be clear. I was just running straight to

Keras installation directory to build Keras.json, silly to get a day.

Here we can use the

>>>gedit ~/.keras/keras.json to open the configuration file. It is important to note that when you enter the execution command, you exit the Python environment with exit (), which should be entered in the Linux environment, as shown in the following figure.


It is very important to note that the file is strange, directly in the change ' backend ' as ' Theano ' does not seem to work, so it is best to also in another file to rewrite the configuration file, and then copy into the original file. So when you have directly modified to complete, still reported backend is TensorFlow, please

Be sure to remember this sentence. The following is the contents of the Keras.json file.


At this point the Keras platform is ready to build.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.