Class Reshape
Represents a Reshape layer. The layer calculates the output tensor by copying the data from the input tensor and using a given shape. The data from the input tensor is unchanged.
Only one of the elements of the shape can be -1. The layer infers the size of this dimension from the remaining dimensions and the length of the input tensor.
Inherited Members
Namespace: Unity.Sentis.Layers
Syntax
[Serializable]
public class Reshape : Layer
Constructors
Reshape(String, String, String, Boolean)
Initializes and returns an instance of Reshape layer.
Declaration
public Reshape(string name, string input, string shape, bool allowZero = false)
Parameters
| Type | Name | Description |
|---|---|---|
| String | name | The name to use for the output tensor of the layer. |
| String | input | The name to use for the input tensor of the layer. |
| String | shape | The name to use for the 1D shape tensor of the layer. |
| Boolean | allowZero | Whether to handle zeros in the shape like numpy. The default value is |
Fields
allowZero
Whether to handle zeros in the shape like numpy.
If the shape has a dimension of size 0 and allowZero is true, the output tensor has a dimension of size zero in the same place.
If the shape has a dimension of size 0 and if allowZero is false, the output tensor has the same dimension as the input tensor at this axis.
Declaration
public bool allowZero
Field Value
| Type | Description |
|---|---|
| Boolean |
Methods
Execute(Tensor[], ExecutionContext)
Executes the layer using the operations and variables from the ExecutionContext and returns the output tensor.
If the layer has more than one output, output tensors are saved to variables.
Declaration
public override Tensor Execute(Tensor[] inputTensors, ExecutionContext ctx)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor[] | inputTensors | |
| ExecutionContext | ctx |
Returns
| Type | Description |
|---|---|
| Tensor |
Overrides
ToString()
Returns a string that represents the Layer.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |