Custom preprocessing layer with Normalization
class CustomPreprocessNormalizationLayer(Layer):
def __init__(self):
super(CustomPreprocessNormalizationLayer, self).__init__()
def call(self, inputs):
normalized_images = inputs / 255.0
return normalized_images
# Custom preprocessing layer with Standardization
class CustomPreprocessStandardizationLayer(Layer):
def __init__(self):
super(CustomPreprocessStandardizationLayer, self).__init__()
def call(self, inputs):
standardized_images = (inputs - tf.math.reduce_mean(inputs)) / tf.math.reduce_std(inputs)
return standardized_images
# Register custom layers
tf.keras.utils.get_custom_objects()['CustomPreprocessNormalizationLayer'] = CustomPreprocessNormalizationLayer
tf.keras.utils.get_custom_objects()['CustomPreprocessStandardizationLayer'] = CustomPreprocessStandardizationLayer