ubuntu keras

安装keras

:~/PycharmProjects$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting keras
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/44/e1/dc0757b20b56c980b5553c1b5c4c32d378c7055ab7bfa92006801ad359ab/Keras-2.4.3-py2.py3-none-any.whl
Requirement already satisfied: numpy>=1.9.1 in /home/ubaba/.local/lib/python3.7/site-packages (from keras) (1.18.1)
Requirement already satisfied: scipy>=0.14 in /home/ubaba/.local/lib/python3.7/site-packages (from keras) (1.4.1)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from keras) (5.1.2)
Requirement already satisfied: h5py in /home/ubaba/.local/lib/python3.7/site-packages (from keras) (3.1.0)
Requirement already satisfied: cached-property; python_version < "3.8" in /home/ubaba/.local/lib/python3.7/site-packages (from h5py->keras) (1.5.2)
Installing collected packages: keras
Successfully installed keras-2.4.3

运行.py文件报错信息
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

keras版本过高,我的是Tensorflow 1.14,因此要安装Keras 2.2.5

Tensorflow版本Keras版本
Tensorflow 2.1
Tensorflow 2.0
Tensorflow 1.15
Keras 2.3.1
Tensorflow 1.14 Keras 2.2.5
Tensorflow 1.13
Tensorflow 1.12
Tensorflow 1.11
Keras 2.2.4
Tensorflow 1.10
Tensorflow 1.9
Keras 2.2.0
Tensorflow 1.8
Tensorflow 1.7
Tensorflow 1.5
Keras 2.1.6
Tensorflow 1.4 Keras 2.0.8
Tensorflow 1.3
Tensorflow 1.2
Tensorflow 1.1
Tensorflow 1.0
Keras 2.0.6
Tensorflow 0.12 Keras 1.2.2

:~/PycharmProjects$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras==2.2.5
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting keras==2.2.5
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f8/ba/2d058dcf1b85b9c212cc58264c98a4a7dd92c989b798823cc5690d062bb2/Keras-2.2.5-py2.py3-none-any.whl (336kB)
100% |████████████████████████████████| 337kB 2.3MB/s
Requirement already satisfied: numpy>=1.9.1 in /home/ubaba/.local/lib/python3.7/site-packages (from keras==2.2.5) (1.18.1)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from keras==2.2.5) (1.12.0)
Requirement already satisfied: keras-applications>=1.0.8 in /home/ubaba/.local/lib/python3.7/site-packages (from keras==2.2.5) (1.0.8)
Requirement already satisfied: h5py in /home/ubaba/.local/lib/python3.7/site-packages (from keras==2.2.5) (3.1.0)
Requirement already satisfied: keras-preprocessing>=1.1.0 in /home/ubaba/.local/lib/python3.7/site-packages (from keras==2.2.5) (1.1.2)
Requirement already satisfied: scipy>=0.14 in /home/ubaba/.local/lib/python3.7/site-packages (from keras==2.2.5) (1.4.1)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from keras==2.2.5) (5.1.2)
Requirement already satisfied: cached-property; python_version < "3.8" in /home/ubaba/.local/lib/python3.7/site-packages (from h5py->keras==2.2.5) (1.5.2)
Installing collected packages: keras
Found existing installation: Keras 2.4.3
Uninstalling Keras-2.4.3:
Successfully uninstalled Keras-2.4.3
Successfully installed keras-2.2.5

原文地址:https://www.cnblogs.com/forest128/p/14117758.html