首先下载anaconda 与pycharm
百度网盘资源:
anaconda:
链接:https://pan.baidu.com/s/1AZk-ADGUvdTrayAnx00jTA
提取码:a1q2
pycharm:
链接:https://pan.baidu.com/s/1_xpnezQLTFWb603K3d9TSQ
提取码:wko6
cmd键
(1)输入清华仓库镜像地址,这样更新会快一些。
1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
2. conda config --set show_channel_urls yes
(2)继续在Anaconda Prompt中利用Anaconda创建一个python3.6的环境,环境名称为tensorflow,输入以下命令。
conda create -n tensorflow python=3.7 ( ps:可能这儿时间会较长一点 )
如果清华源不好用
解决 (删除清华镜像换成华科的):
1 conda config --remove-key channels
2 conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
3 conda config --set show_channel_urls yes
4 conda create -n tensorflow python=3.6
下一步安装tensorflow
1、activate tensorflow (打开环境) (关闭环境:deactivate tensorflow)
2. pip install --index-url https://pypi.douban.com/simple tensorflow
(ps:此源可以下很多东西。或者使用pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxxx 从清华镜像获取库。)
安装pycharm
具体细节参照下链接的下半段
https://www.cnblogs.com/yuxuefeng/articles/9235431.html
调试程序
import numpy as np
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
a = np.array([[1, 2, 3], [4, 5, 6]])
print(a)
#b=tf.reduce_sum(a)
#c=tf.reduce_sum(a)
# b = tf.reduce_sum(a, reduction_indices=[0])
b = tf.reduce_sum(a, axis=0)
# c = tf.reduce_sum(a, reduction_indices=[1])
c = tf.reduce_sum(a, axis=1)
# d = tf.reduce_sum(a)
d = tf.reduce_sum(a)
with tf.compat.v1.Session() as sess:
b_result, c_result, d_result = sess.run([b, c, d]) # type: (b, c, d)
print(b_result)
print(c_result)
print(d_result)
结果如果有错误,上网查原因。大部分原因是没有对应的包。按照网上操作的来就好了
我的.condarc文件内容
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- defaults
.condarc文件目录
C:\Users\16341