Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install keras and tensorflow in Anaconda

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to install keras and tensorflow in Anaconda, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Keras is an advanced neural network API written in Python, which can run with TensorFlow, CNTK, or Theano as the back end. The development focus of Keras is to support rapid experimentation. The key to good research is to be able to convert your ideas into experimental results with minimal delay. So keras is just a front-end API that needs to install its back-end before using it. According to the mainstream, it is recommended to install TensorFlow as the backend of Keras.

Download and install Anaconda:

Anaconda download

Installation steps:

If a multi-user operating system chooses All Users, a single user chooses Just Me

Select the appropriate installation path

Then check this to configure the environment variables automatically

Finally, just wait for the installation to complete.

After installation, open the 'cmd' input' python', as shown below, the installation is successful.

Download and install Tensorflow:

Configure domestic images:

Conda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ conda config-- add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/ conda config-- set show_channel_urls yes # sets the channel address to be displayed when searching

Enter conda config-show channels to display the mirror source

Enter: conda config-- remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ to remove the mirror source

Conda configuration of Tsinghua Source

Create a virtual environment: open Anaconda Prompt and establish a conda computing environment called tensorflow. Enter: conda create-n tensorflow python=3.6 to activate the tensorflow environment. Input: activate tensorflow input: python-- version to check whether to switch to the python3.6 work environment

Install tensorflow: after installation, this environment will appear in anaconda navigator as shown below. If it does not appear, check the above environment path problem.

Activate the environment, continue to enter: activate tensorflow in Anaconda Prompt and then enter the command pip install tensorflow==2.0-I https://pypi.doubanio.com/simple

Specify version 2.0, because the latest version of tensorflow has integrated CPU and GPU versions, which is too large for students to learn.

Note: if the python version is higher than 3.7tensorflow, it is not supported! Then you can manually downgrade python, which shows the benefits of creating a virtual environment!

Then choose the appropriate version here.

Download and install Keras:

Enter the command pip install keras==2.3.1-I https://pypi.doubanio.com/simple to start installing kares.

It is important to declare that the keras version is 2.3.1. Since our tensorflow version is 2.0.0, it cannot be used if there is no correspondence between versions.

Version correspondence between tensorflow and keras

View the tensorflow and keras installation commands:

Enter python in Anaconda Prompt, followed by the following code

Import tensorflow as tftf.__version__

The installation is successful when shown in Anaconda Navigator as follows

Enter import keras to display Using TensorFlow backend. You can start your machine learning journey!

4. Add tensorflow virtual environment to jupyter:

Install ipykernel first

Execute the command line under Anaconda Prompt: conda install ipykernel

Create kernel file in virtual environment

Execute the command line under Anaconda Prompt: conda install-n environment name ipykernel

Activate the conda environment

Execute command line under Anaconda Prompt: conda activate environment name

Write the environment to the kernel of notebook

Execute the command line under Anaconda Prompt: python-m ipykernel install-- user-- name environment name-- display-name "environment name displayed in jupyter"

Open the notebook server

You can also switch kernels

On how to install keras and tensorflow in Anaconda to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report