第四节 生成随机张量和张量合并

import tensorflow as tf

# 生成全为0的张量
zero = tf.zeros([3, 5], tf.float32)

# 生成全为1的张量
ones = tf.ones([3, 5], tf.float32)

# [2, 3]两行三列,生成随机值张量,mean平均值,stddev标准差
rdm = tf.random_normal([2, 3], mean=0, stddev=1)

# 转换张量的数据类型
tf.cast([[1, 2, 3], [1, 2, 3]], tf.float32)

# 合并张量,axis=0按行合并
a = [[1, 2, 3], [4, 5 ,6]]
b = [[7, 8, 9], [10, 10, 10]]
c = tf.concat([a, b], axis=0)

猜你喜欢

转载自www.cnblogs.com/kogmaw/p/12597803.html
今日推荐