tensorflow2.0基础(二)

#布尔类型 
import tensorflow as tf 
a = tf.constant(True) 
a 
<tf.Tensor: id=11, shape=(), dtype=bool, numpy=True>
import tensorflow as tf 
a = tf.constant([True, False]) 
a 
<tf.Tensor: id=12, shape=(2,), dtype=bool, numpy=array([ True, False])>
import tensorflow as tf 
a = tf.constant(True) 
a == True #仅数值比较 
<tf.Tensor: id=15, shape=(), dtype=bool, numpy=True>
import tensorflow as tf 
a = tf.constant(True) 
a is True #TF布尔类型张量与python布尔类型比较 
False
#数值精度 
import tensorflow as tf 
tf.constant(123456789, dtype = tf.int16) 
<tf.Tensor: id=17, shape=(), dtype=int16, numpy=-13035>
import tensorflow as tf 
a = tf.constant(123456789, dtype = tf.int32) 
b = tf.constant(123456789, dtype = tf.int16) 
a,b 
(<tf.Tensor: id=25, shape=(), dtype=int32, numpy=123456789>,
 <tf.Tensor: id=26, shape=(), dtype=int16, numpy=-13035>)
import tensorflow as tf 
import numpy as np 
a = tf.constant(np.pi, dtype = tf.float32) 
b = tf.constant(np.pi, dtype = tf.float64) 
print(a) 
print(b) 
tf.Tensor(3.1415927, shape=(), dtype=float32)
tf.Tensor(3.141592653589793, shape=(), dtype=float64)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值