作者:Bboy龙超 | 来源:互联网 | 2023-08-04 17:03
1.环境依赖
Centos7
组件 | 版本 |
Python | 2.7.5 |
TensorFlow | 0.14.0 |
pyhton依赖库
Package Version -------------------- --------- absl-py 0.8.0 astor 0.8.0 backports.weakref 1.0.post1 enum34 1.1.6 funcsigs 1.0.2 futures 3.3.0 gast 0.2.2 google-pasta 0.1.7 grpcio 1.23.0 h5py 2.9.0 Keras-Applications 1.0.8 Keras-Preprocessing 1.1.0 Markdown 3.1.1 mock 3.0.5 numpy 1.16.5 pip 19.2.3 protobuf 3.9.1 setuptools 41.2.0 six 1.12.0 tensorboard 1.14.0 tensorflow 1.14.0 tensorflow-estimator 1.14.0 termcolor 1.1.0 Werkzeug 0.15.5 wheel 0.33.6 wrapt 1.11.2
2.资源准备
安装包下载
百度云盘链接:https://pan.baidu.com/s/1cm9mZpP1JRwyGpq945ffaQ
提取码:8bxj
3.安装
a).安装python-devel
## 在线安装 yum install python-devel ## 离线安装 rpm -ivh python-devel-2.7.5-80.el7_6.x86_64.rpm
b).安装virtualenv
## 在线安装 pip install virtualenv ## 离线安装
c).安装tensorflow
进入虚拟机,安装tensorflow
## Step1: 创建虚拟机 virtualenv tensorflow ## Step2: 进入虚拟机 source ./tensorflow/bin/activate
## 在线安装 pip install tensorflow ## 离线安装 pip install --no-index --find-links=/path/to/tensorflow_1.14.0_package -r tensorflow_requirement.txt
4.测试
测试代码
import tensorflow as tf mnist = tf.keras.datasets.mnist (x_train, y_train),(x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0, x_test / 255.0 model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax') ]) model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy']) model.fit(x_train, y_train, epochs=5) model.evaluate(x_test, y_test)
执行测试
python test.py
测试结果
5.环境依赖下载
## python-devel http://mirror.centos.org/centos/7/updates/x86_64/Packages/python-devel-2.7.5-80.el7_6.x86_64.rpm ## tensorflow-1.14.0 https://files.pythonhosted.org/packages/d3/59/d88fe8c58ffb66aca21d03c0e290cd68327cc133591130c674985e98a482/tensorflow-1.14.0-cp27-cp27mu-manylinux1_x86_64.whl ## pip-19.2.3 https://files.pythonhosted.org/packages/00/9e/4c83a0950d8bdec0b4ca72afd2f9cea92d08eb7c1a768363f2ea458d08b4/pip-19.2.3.tar.gz ## virtualenv https://files.pythonhosted.org/packages/f7/69/1ad2d17560c4fc60170056dcd0a568b83f3453a2ac91155af746bcdb9a07/virtualenv-16.7.4-py2.py3-none-any.whl