Skip to content

rescaling

Rescaling Layer API

This module provides classes to build rescaling layers.

Classes:

Classes

Rescaling1D

Rescaling1D(scale: float, **kwargs)

Rescale the input samples.

Parameters:

  • scale (float) –

    The scaling factor.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def __init__(self, scale: float, **kwargs):
    """Rescale the input samples.

    Args:
        scale (float): The scaling factor.
    """
    super().__init__(**kwargs)
    self.scale = scale

Functions

augment_samples
augment_samples(inputs) -> keras.KerasTensor

Rescale a batch of samples during training.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def augment_samples(self, inputs) -> keras.KerasTensor:
    """Rescale a batch of samples during training."""
    samples = inputs[self.SAMPLES]
    return samples * self.scale
compute_output_shape
compute_output_shape(input_shape, *args, **kwargs)

Compute output shape.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def compute_output_shape(self, input_shape, *args, **kwargs):
    """Compute output shape."""
    return input_shape
get_config
get_config()

Serialize the configuration.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def get_config(self):
    """Serialize the configuration."""
    config = super().get_config()
    config.update(scale=self.scale)
    return config

Rescaling2D

Rescaling2D(scale: float, **kwargs)

Rescale the input samples.

Parameters:

  • scale (float) –

    The scaling factor.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def __init__(self, scale: float, **kwargs):
    """Rescale the input samples.

    Args:
        scale (float): The scaling factor.
    """
    super().__init__(**kwargs)
    self.scale = scale

Functions

augment_samples
augment_samples(inputs) -> keras.KerasTensor

Rescale a batch of samples during training.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def augment_samples(self, inputs) -> keras.KerasTensor:
    """Rescale a batch of samples during training."""
    samples = inputs[self.SAMPLES]
    return samples * self.scale
compute_output_shape
compute_output_shape(input_shape, *args, **kwargs)

Compute output shape.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def compute_output_shape(self, input_shape, *args, **kwargs):
    """Compute output shape."""
    return input_shape
get_config
get_config()

Serialize the configuration.

Source code in neuralspot_edge/layers/preprocessing/rescaling.py
def get_config(self):
    """Serialize the configuration."""
    config = super().get_config()
    config.update(scale=self.scale)
    return config