zl程序教程

您现在的位置是:首页 >  其他

当前栏目

slim.flatten——将输入扁平化但保留batch_size,假设第一维是batch

输入 第一 size 保留 Batch 假设 扁平化 Flatten
2023-09-14 09:11:53 时间

slim.flatten(inputs,outputs_collections=None,scope=None)

(注:import tensorflow.contrib.slim as slim)
将输入扁平化但保留batch_size,假设第一维是batch。
Args:
inputs: a tensor of size [batch_size, …].
outputs_collections: collection to add the outputs.
scope: Optional scope for name_scope.
如:

test=([[[1,2,3],[4,5,6],[7,8,9]],[[10,11,12],[13,14,15],[16,17,27]],[[18,19,20],[21,22,23],[24,25,26]]])    #shape is (3,3,3)
test=slim.fatten(test)
test.eval()
array([[ 1,  2,  3, ...,  7,  8,  9],
       [10, 11, 12, ..., 16, 17, 27],
       [18, 19, 20, ..., 24, 25, 26]], dtype=int32)
test.get_shape()
TensorShape([Dimension(3), Dimension(9)])  #(3,9)