tensorflow reshape,range用法

import tensorflow as tf
x= tf.constant([
                 [[2,3],[4,5]],
                 [[6,7],[8,9]]
                 
               ],
                 tf.int32)

d1=tf.range(0, tf.shape(x)[0])

print(d1.numpy())


d2=tf.tile( d1, multiples=[tf.shape(x)[1]])


print(d2.numpy())

d3=tf.reshape(d2,shape = tf.shape(x)[:-1])

print(d3.numpy())
posted @ 2022-08-19 22:51  luoganttcc  阅读(2)  评论(0)    收藏  举报