I am new to Tensorflow, and am trying to train a specific deep learning neural network. I am using Tensorflow (2.11.0) to get a deep neural network model which is described below. The data which I use is also given below:
Data:
Here is some example data. For sake of ease we can consider 10 samples in data. Here, each sample has shape: (128,128)
.
One can consider the below code as example training data.
x_train = np.random.rand(10, 128, 128, 1)
Normalization layer:
normalizer = tf.keras.layers.Normalization(axis=-1)
normalizer.adapt(x_train)
Build model:
def build_and_compile_model(norm):
model = tf.keras.Sequential([
norm,
layers.Conv2D(128, 128, activation='relu'),
layers.Conv2D(3, 3, activation='relu'),
layers.Flatten(),
layers.Dense(units=32, activation='relu'),
layers.Dense(units=1)
])
model.compile(loss='mean_absolute_error', optimizer=tf.keras.optimizers.Adam(0.001))
return model
When I do
dnn_model = build_and_compile_model(normalizer)
dnn_model.summary()
I get the below error:
ValueError: The channel dimension of the inputs should be defined. The input_shape received is (None, None, None, None), where axis -1 (0-based) is the channel dimension, which found to be `None`.
What am I doing wrong here?
I have tried to get insights from this, this, this and this. But, I have not found a workable solution yet.
What should I do to remove the error and get the model to work?
I will appreciate any help.