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


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)



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM