Created
October 1, 2020 16:50
-
-
Save securetorobert/35a7addfa93d14e2b3ad2b6dce8ebc87 to your computer and use it in GitHub Desktop.
Implement normalization in a layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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