win10在anaconda3下安装TensorFlow和pytorch(CPU版)

安装TensorFlow
终端输入

conda create -n tensorflow python=3.6

激活TensorFlow环境

C:\> activate tensorflow

安装TensorFlow

C:\> pip3 install --upgrade tensorflow

在Spyder中使用TensorFlow
激活TensorFlow
输入conda install spyder

进入Spyder测试

(tensorflow)C:\> spyder

测试代码:

import tensorflow as tf
hello = tf.constant('Hello,TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

正确输出:

b'Hello,TensorFlow!'

卸载TensorFlow

activate tensorflow
pip uninstall tensorflow

安装pytorch

pip install http://download.pytorch.org/whl/cpu/torch-0.4.0-cp36-cp36m-win_amd64.whl 

pip install torchvision    

激活环境

activate pytorch36

测试语句:

import torch
import numpy as np
np_data=np.arange(6).reshape((2,3))
torch_data=torch.from_numpy(np_data)
print('np_data',np_data)

测试结果:

np_data [[0,1,2]
[3,4,5]]

猜你喜欢

转载自blog.csdn.net/weixin_44190201/article/details/87911715