Skip to content

Instantly share code, notes, and snippets.

@securetorobert
Created October 1, 2020 16:50
Show Gist options
  • Save securetorobert/35a7addfa93d14e2b3ad2b6dce8ebc87 to your computer and use it in GitHub Desktop.
Save securetorobert/35a7addfa93d14e2b3ad2b6dce8ebc87 to your computer and use it in GitHub Desktop.
Implement normalization in a layer
class Normalize(layers.Layer):
""" Custom Layer for Preprocessing Input """
def __init__(self):
""" Constructor """
super(Normalize, self).__init__()
def build(self, input_shape):
""" Handler for Input Shape """
self.kernel = None
@tf.function
def call(self, inputs):
""" Handler for layer object is callable """
inputs = inputs / 255.0
return inputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment