Search code examples
kerasbatch-normalization

Is it possible to apply normalization of input data via some layers?


I am building a Keras RNN model and preprocess my input to normalize (between 0 and 1).

I am wondering if there is a way to achieve the same through some first layer as a part of the model itself?


Solution

  • Since the model only has batch-wise information, it cannot do normalization with global max/min itself. However, if you can somehow pass your global max/min to the model, you might try this:

    from keras.layers import Lambda
    model.add(Lambda(lambda x: (x-min) / (max-min))