查看张量的形状及阶的个数
import tensorflow as tf
import os
os.environ["CUDA_VISIBLE_DEVICES"]="0"
tf.compat.v1.disable_eager_execution()
s0 = 1
s1 = [1,2,3]
s2 = [[1,2,3],[4,5,6],[7,8,9]]
s3 = [[[1,2,3]],[[4,5,6]],[[7,8,9]]]
b = tf.constant(s0)
shape1 = tf.shape(b)
rank1 = tf.rank(b)
session = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
print('张量的值:')
print(session.run(b))
print('张量的形状:')
print(session.run(shape1))
print('张量的阶数:')
print(session.run(rank1))
设计一个感知器来实现逻辑与(and)的运算
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。