Tensorflow的Hello和做加法运算

import tensorflow as tf
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'  # 忽略警告

msg = tf.constant("hello Tensor Flow!")

with tf.compat.v1.Session() as sess:
    print(sess.run(msg).decode())
    sess.close()  # 创建一个with对话 在对应的结束建议关闭对话
# 做加法运算
v1 = tf.constant([1, 2, 3, 4])
v2 = tf.constant([4, 3, 2, 1])
ret = tf.add(v1, v2)

# 做除法运算
d1 = tf.constant(1)
d2 = tf.constant(3)
res = tf.divide(d1, d2)

with tf.compat.v1.Session() as sess:
    print(sess.run(v1))
    print(sess.run(v2))
    print(sess.run(ret))
    print(sess.run(res))
    sess.close()

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值