Tensorflow基础8:张量生成合并与切片

Tensorflow

基础8:张量生成合并与切片

生成

tf.zeros()
tf.ones()
tf.eye()
tf.constant()
random_normal() 标准正态分布
rabdin_uniform 生成均匀分布
tf.matmul() 点积
tf.range()
tf.linespace()
tf.random_normal(shape=(10,), mean=0.0, stddev=1.0)

<tf.Tensor ‘random_normal_2:0’ shape=(10,) dtype=float32>

合并和切片

a = tf.constant([[1,2,3],[1,2,3]])
b = tf.constant([[2,2,3],[1,2,1]])
c = tf.constant(np.random.randint(0,100,(10,5)))

with tf.Session() as sess:
    display(sess.run(c))

array([[48, 84, 72, 35, 62],
[91, 28, 82, 20, 9],
[ 3, 0, 14, 84, 87],
[29, 22, 0, 3, 55],
[82, 45, 88, 20, 84],
[79, 86, 95, 4, 6],
[12, 23, 23, 21, 21],
[69, 65, 46, 62, 42],
[47, 77, 95, 33, 53],
[46, 94, 35, 83, 5]])

with tf.Session() as sess:
#     print(sess.run([a,b]))
#     print(sess.run(a[:-1,:-1]))
    crop = tf.random_crop(value=c,size=[1,4])
    print(sess.run(crop))

[[28 82 20 9]]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值