准备工作
查看conda:
conda --version
查看python:
python --version
安装TensorFlow
1.打开Anaconda prompt,新建一个环境(不建议用自带的base)
conda create -n tf2 python=3.6.5
conda activate tf2
3.安装TensorFlow2.0.0
pip install tensorflow==2.0.0
安装keras
1.打开Anaconda prompt切换到有TensorFlow的环境下:
conda activate tf2
2.安装keras前先依次执行以下两个命令:
conda install mingw libpython pip install theano
pip install keras==2.3.1
import keras from keras.datasets import mnist (train_images,train_labels),(test_images,test_labels) = mnist.load_data() #加载数据 print('shape of train images is ',train_images.shape) print('shape of train labels is ',train_labels.shape) print('train labels is ',train_labels) print('shape of test images is ',test_images.shape) print('shape of test labels is',test_labels.shape) print('test labels is',test_labels)
配置pycharm
注意
在对刚才配置好的tf2环境安装别的包时(如pandas,numpy等等),还是要从Anaconda Prompt中使用pip语句安装,不能使用pycharm中的“+”
Anaconda Prompt常用语句
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/199909.html原文链接:https://javaforall.net
