Tensorflow.js tf.layers.cropping2D() Function
The tf.layers.cropping2D() function is used to crop an input at the top, bottom, left, and right side of an image tensor.
Input Shape: 4D tensor with shape:
- If dataFormat is channelsLast: [batch, rows, cols, channels]
- If data_format is channelsFirst: [batch, channels, rows, cols].
Output Shape: 4D with shape:
- If dataFormat is channelsLast: [batch, croppedRows, croppedCols, channels]
- If dataFormat is channelsFirst: [batch, channels, croppedRows, croppedCols].
- args: It is an object type that accepts the following properties:
- cropping (number|[number, number]|[[number, number], [number, number]]): The dimension of the cropping along the width and the height.
- dataFormat: The data format. This specifies the order in which the dimensions in the inputs are ordered. channelsLast is the default value.
- inputShape: If this property is set, it will be utilized to construct an input layer that will be inserted before this layer.
- batchInputShape: If this property is set, an input layer will be created and inserted before this layer.
- batchSize: If batchInputShape isn’t supplied and inputShape is, batchSize is utilized to build the batchInputShape.
- dtype: It is the kind of data type for this layer. float32 is the default value. This parameter applies exclusively to input layers.
- name: This is the layer’s name and is of string type.
- trainable: If the weights of this layer may be changed by fit. True is the default value.
- weights: The layer’s initial weight values.
Returns: It returns an object (Cropping2D).
[ null, 6, 6, 4 ]
[ null, 10, 5, 1 ]