Anaconda 安装TensorFlow

1、安装 Anaconda 

   https://www.anaconda.com/products/individual
   
   https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
   
   
2、添加环境变量

    X:\Anaconda3\condabin

3、安装TensorFlow

    conda create -n tensorflow python
 
    pip install tensorflow

or


    pip install --upgrade --ignore-installed tensorflow


 
4、conda activate tensorflow
    命令行提示:(tensorflow) D:\TensorFlow>

5、jupyter notebook

Anaconda 安装TensorFlow_第1张图片

     Demo:

import tensorflow as tf;

print(tf.__version__)

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, verbose=2)

   运行结果:

Anaconda 安装TensorFlow_第2张图片

 

6、conda deactivate

你可能感兴趣的:(TensorFlow,tensorflow,python,人工智能)