reshape中的参数shape与actual_shape需要一样吗
Created by: jiangjiajun
import paddle.fluid as fluid
inputs = fluid.layers.data(dtype='float32', shape=[10, 10], name='inputs', append_batch_size=False)
actual_shape = fluid.layers.shape(inputs)
result = fluid.layers.reshape(inputs, shape=[1, -1], actual_shape=actual_shape)
如上面代码所示,shape填的是[1, -1],也就是[1, 100], 但actual_shape中其实是[10, 10],所以最终得到输出result值也是[10, 10],但如果print(result)可以看得是
name: "reshape2_0.tmp_0"
type {
type: LOD_TENSOR
lod_tensor {
tensor {
data_type: FP32
dims: 1
dims: 100
}
}
}
persistable: false
像这样的话,这个result作为后续layer的输入会存在问题吗,因为上面这个dims与实际输出值已经不同了