I am trying to use EfficientNetV2L for my simple regression problem. I will use my lab experiment data later in replacement of this current simple regression problem. I am using 100 examples of 75x75 size. Example one contains all 1’s in 75x75 matrix, example 2 contains all 2’s in 75x75 matrix and so on. Correspondingly, labels are in a vector with a range from 1 to 100. The problem I am facing is that all the predictions have the same value (wrong predictions). Someone please help me in this problem. Thank you.

# EfficientNetV2L Example with Plain Matrix

import tensorflow as tf

from tensorflow import keras

from keras import Sequential

from keras import layers

from keras.layers import Dense, Dropout

import numpy as np

from keras import optimizers, Model

from keras.optimizers import SGD, RMSprop

from keras import losses

from tensorflow.keras.applications import EfficientNetV2L

import os

import matplotlib.pyplot as plt

dum = np.ones(shape=(75,75),dtype=float)

x=np.ndarray(shape=(75,75))

y=np.array([])

for i in range(1,101):

x = np.vstack((x,dum*i))

y = np.append(y,i)

x = np.delete(x, range(0,75), axis = 0)

x_reshp = np.reshape(x, (-1,75,75,1))

x_train = x_reshp/np.max(x_reshp)

y_train = y/np.max(y)

base_model = tf.keras.applications.efficientnet_v2.EfficientNetV2L(

include_top=False,

weights=None,

# input_tensor=None,

input_shape=(75,75,1),

pooling= ‘avg’,

# classes=1,

# classifier_activation=None,

include_preprocessing=False

)

x = base_model.output

# x = layers.Flatten()(x)

x = Dense(50, activation=‘relu’)(x)

# x = Dropout(0.5)(x)

x = Dense(10, activation=‘relu’)(x)

Preds = Dense(1)(x)

model = Model(inputs=base_model.input, outputs = Preds)

model.compile(keras.optimizers.Adam(learning_rate= 0.0001),loss=‘mse’,metrics=[‘mae’])

# model.summary()

# Train the model

history = model.fit(x_train, y_train, epochs=50,verbose=2)

x_pred = x_train[0:100]

z = model.predict(x_pred)

print('Predicted Value is = ', z*(np.max(y)))

acc = history.history[‘mae’]

loss = history.history[‘loss’]

epochs = range(len(acc))

plt.plot(epochs, acc, ‘r’, label=‘Training MAE’)

plt.plot(epochs, loss, ‘b’, label=‘Training Loss’)

plt.legend()

plt.show()