tf.squeeze

tf.squeeze(input, squeeze_dims=None, name=None)

Removes dimensions of size 1 from the shape . Of a tensor
remove all sizes from the tensor is of dimension 1

Input: tensor. Enter the squeeze.
squeeze_dims: optional list ints. The default is[]. If you specify, you can only squeeze the size listed. Dimensions index starts at 0. Dimension 1 is not squeezing a mistake.

示例:
print(“sampled_indices1:”,sampled_indices)
sampled_indices = tf.squeeze(sampled_indices,axis=-1)
print(“sampled_indices2:”,sampled_indices)

输出:
sampled_indices1: tf.Tensor(
[[26]
[46]

[27]
[12]], shape=(100, 1), dtype=int64)
sampled_indices2: tf.Tensor(
[26 46 … 27 12], shape=(100,), dtype=int64)

Published 21 original articles · won praise 18 · views 1458

Guess you like

Origin blog.csdn.net/zephyr_wang/article/details/104061318