TensorFlow 测试样例tf.constant

TensorFlow 测试样例tf.constant
在这里插入图片描述

#!/usr/bin/env python3.7
# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
a=tf.constant(2,name="a")
b=tf.constant(4,name="b")
result=a+b
#print(result)#直接输出,只会得到一个tensor
sess=tf.Session()#创建会话,
print("the result is ",sess.run(result))#运行结果,打印是会话session 运行run之后的结果

输出结果

the result is  6

(从今天开始记录一下笔记)

发布了46 篇原创文章 · 获赞 9 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_43826596/article/details/90200778
今日推荐