random_crop
Random Crop Layers API
This module provides classes to build random crop layers.
Classes:
-
RandomCrop1D
–Random crop 1D
-
RandomCrop2D
–Random crop 2D
Classes
RandomCrop1D
Randomly crop 1D input samples.
Parameters:
-
duration
(int
) –Duration of the output samples.
-
unique_batch
(bool
, default:False
) –If True, each sample in the batch will have a unique crop.
Example:
duration = 100
lyr = RandomCrop1D(duration=duration)
x = np.random.randn(32, 1000, 1)
y = lyr(x, training=True)
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
Functions
random_crop
Randomly crop single sample
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
get_random_transformations
Generate random start indices for cropping.
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
augment_sample
Augment single sample with random crop.
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
compute_output_shape
Compute the output shape of the layer.
get_config
Serializes the configuration of the layer.
RandomCrop2D
Randomly crop 2D input samples.
Parameters:
-
height
(int
) –Height of the output samples.
-
width
(int
) –Width of the output samples.
-
unique_batch
(bool
, default:False
) –If True, each sample in the batch will have a unique crop.
Example:
height = 32
width = 32
lyr = RandomCrop2D(height=height, width=width)
x = np.random.randn(32, 64, 64, 3)
y = lyr(x, training=True)
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
Functions
random_crop
Randomly crop single sample
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
get_random_transformations
Generate random start indices for cropping.
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
augment_sample
Augment single sample with random crop.
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
compute_output_shape
Compute the output shape of the layer.
Source code in neuralspot_edge/layers/preprocessing/random_crop.py
get_config
Serializes the configuration of the layer.