
人工智能深度学习入门练习之(23)TensorFlow2基础语法之练习
发布日期:2021-05-14 00:18:28
浏览次数:24
分类:博客文章
本文共 4304 字,大约阅读时间需要 14 分钟。
1���������������
������tensorflow1.x���
import tensorflow.compat.v1 as tftf.disable_v2_behavior() # ���������������������������������������assert tf.__version__.startswith('2.')# 1.���������������������# ������2���������������������������������������a_ph = tf.placeholder(tf.float32, name='variable_a')b_ph = tf.placeholder(tf.float32, name='variable_b')# ���������������������������������������������c_op = tf.add(a_ph, b_ph, name='variable_c')# 2.���������������������# ������������������sess = tf.InteractiveSession()# ������������������������������������������init = tf.global_variables_initializer()sess.run(init) # ���������������������������������������# ������������������������������������������������c_numpy = sess.run(c_op, feed_dict={a_ph: 2., b_ph: 4.})# ������������������������������������������������c_numpyprint('a+b=',c_numpy)
���������
C:\Anaconda3\python.exe "C:\Program Files\JetBrains\PyCharm 2019.1.1\helpers\pydev\pydevconsole.py" --mode=client --port=63269import sys; print('Python %s on %s' % (sys.version, sys.platform))sys.path.extend(['C:\\app\\PycharmProjects', 'C:/app/PycharmProjects'])Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]Type 'copyright', 'credits' or 'license' for more informationIPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.PyDev console: using IPython 7.12.0Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] on win32runfile('C:/app/PycharmProjects/tensorflow/Test/__init__.py', wdir='C:/app/PycharmProjects/tensorflow/Test')2020-11-10 15:25:43.753169: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found2020-11-10 15:25:43.755830: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.WARNING:tensorflow:From C:\Anaconda3\lib\site-packages\tensorflow\python\compat\v2_compat.py:96: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.Instructions for updating:non-resource variables are not supported in the long term2020-11-10 15:26:07.126862: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.2020-11-10 15:26:07.199289: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x1ccbe5249e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:2020-11-10 15:26:07.201115: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version2020-11-10 15:26:07.206639: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found2020-11-10 15:26:07.209239: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)a+b= 6.0
������tensorflow2.x���
import tensorflow as tfa=tf.constant(2.0)b=tf.constant(4.0)print('{0}+{1}={2}'.format(a,b,a+b))
���������
C:\Anaconda3\python.exe "C:\Program Files\JetBrains\PyCharm 2019.1.1\helpers\pydev\pydevconsole.py" --mode=client --port=63589import sys; print('Python %s on %s' % (sys.version, sys.platform))sys.path.extend(['C:\\app\\PycharmProjects', 'C:/app/PycharmProjects'])Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]Type 'copyright', 'credits' or 'license' for more informationIPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.PyDev console: using IPython 7.12.0Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] on win32runfile('C:/app/PycharmProjects/tensorflow/Test/__init__.py', wdir='C:/app/PycharmProjects/tensorflow/Test')2020-11-10 15:46:36.564267: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found2020-11-10 15:46:36.566052: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.2.0+4.0=6.0
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年05月03日 23时32分57秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
基于 HTML5 WebGL 的污水处理厂泵站自控系统
2021-05-09
django-表单之模型表单渲染(六)
2021-05-09
c++之程序流程控制
2021-05-09
spring-boot-2.0.3之redis缓存实现,不是你想的那样哦!
2021-05-09
有道云笔记 同步到我的博客园
2021-05-09
李笑来必读书籍整理
2021-05-09
Hadoop(十六)之使用Combiner优化MapReduce
2021-05-09
《机器学习Python实现_10_06_集成学习_boosting_gbdt分类实现》
2021-05-09
CoreCLR源码探索(八) JIT的工作原理(详解篇)
2021-05-09
IOS开发Swift笔记16-错误处理
2021-05-10
flume使用中的一些常见错误解决办法 (地址已经使用)
2021-05-10
andriod 开发错误记录
2021-05-10
C语言编译错误列表
2021-05-10
看明白这两种情况,才敢说自己懂跨链! | 喵懂区块链24期
2021-05-10
张一鸣:创业7年,我经历的5件事
2021-05-10
《web安全入门》(四)前端开发基础Javascript
2021-05-10
python中列表 元组 字典 集合的区别
2021-05-10