生成式对抗网络基础——关于安装TensorFlow的一些问题

对于现有的深度学习来说,TensorFlow无疑是一个良好的神经网络框架,它支持使用多种编程语言以及多种平台,还支持使用GPU加速模型训练,并为模型训练做了很多的优化。

当然对于初学者来说,GPU无论是云服务器还是实验室使用都是不划算的,对此对拥有独立显卡的,一般使用CPU版。

参考书目,在cmd种执行操作:

pip install --ignore-installed --upgrade tensorflow

然后卡的直接爆炸.....,一番百度了解后,发现这是直接使用的外国镜像。

于是直接输入:pip installed tensorflow 试了一下,速度从可怜的17KB升到170KB左右,依旧慢到爆炸,这时候浏览到大佬的解决方案,他使用的是国内的镜像。

pip installed tensorflow-ihttps://pypi.douban.com/smiple

直接起飞,一分钟下载完毕。

然后打开pycharm进行验证操作,看看装好没有。

import tensorflow as tf

hello = tf.constant('hello,tf')
sess = tf.Session()
print(sess.run(hello))

然后又鸡儿了,百度发现,这是版本的问题,现在2.70版本对1.x系列代码的实现有所不同,修改代码如下所示:

import tensorflow as tf
tf.compat.v1.disable_eager_execution()  # 解决兼容问题
hello = tf.constant('hello,tf')
sess = tf.compat.v1.Session()
print(sess.run(hello))

终于可以愉快的跑代码了

猜你喜欢

转载自blog.csdn.net/qq_40981869/article/details/122363538