Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 2.32 KB

reshape.md

File metadata and controls

51 lines (40 loc) · 2.32 KB
title
Reshape Layer

Reshape Layer

The Reshape layer can be used to change the dimensions of its input, without changing its data. Just like the Flatten layer, only the dimensions are changed; no data is copied in the process.

Output dimensions are specified by the ReshapeParam proto. Positive numbers are used directly, setting the corresponding dimension of the output blob. In addition, two special values are accepted for any of the target dimension values:

  • 0 means "copy the respective dimension of the bottom layer". That is, if the bottom has 2 as its 1st dimension, the top will have 2 as its 1st dimension as well, given dim: 0 as the 1st target dimension.
  • -1 stands for "infer this from the other dimensions". This behavior is similar to that of -1 in numpy's or [] for MATLAB's reshape: this dimension is calculated to keep the overall element count the same as in the bottom layer. At most one -1 can be used in a reshape operation.

As another example, specifying reshape_param { shape { dim: 0 dim: -1 } } makes the layer behave in exactly the same way as the Flatten layer.

Parameters

{% highlight Protobuf %} {% include proto/ReshapeParameter.txt %} {% endhighlight %}