When I execute the following Keras code:
from tensorflow import keras
from tensorflow.keras import layers
n_input = 100
n_entries = 10
n_features = 2
features = np.random.random(n_entries*n_input*n_features)
features = features.reshape((n_entries, n_input, n_features))
model = keras.Sequential()
norm = layers.Normalization(-1)
norm.adapt(features)
model.add(norm)
print(norm.output)
I get <KerasTensor: shape=(None, None, 2) dtype=float32 (created by layer 'normalization_28')> with 2D output shape as expected.
However, changing n_features to 1:
from tensorflow import keras
from tensorflow.keras import layers
n_input = 100
n_entries = 10
n_features = 1
features = np.random.random(n_entries*n_input*n_features)
features = features.reshape((n_entries, n_input, n_features))
model = keras.Sequential()
norm = layers.Normalization(-1)
norm.adapt(features)
model.add(norm)
print(norm.output)
I get <KerasTensor: shape=(None, None, None) dtype=float32 (created by layer 'normalization_29')>, with None shape, where I would expect 1.
This breaks the pipeline, making 1D features an exceptional case.
What is the reason for this?