I have 8000 images of circles on a black-background. Each label is the x coordinate of the circle. Each image is size (128,128,3). My training loss is starting at 2000 and ending at 10 while validation loss is staying around 200. Also, I am normalizing each image by dividing it by 255.
images_array is shape: (8000,128,128,3)
y is shape: (8000,1)
Here is my code:
from sklearn.model_selection import train_test_split
X_train, X_temp, y_train, y_temp = train_test_split(images_array, y, test_size=0.2, random_state=42)
X_val, X_test, y_val, y_test = train_test_split(X_temp, y_temp, test_size=0.5, random_state=42)
import tensorflow as tf
X_train = tf.convert_to_tensor(X_train)
y_train = tf.convert_to_tensor(y_train)
from tensorflow import keras
from tensorflow.keras import layers, Model
from tensorflow.keras.models import Sequential
inputs = keras.Input(shape=(128, 128, 3))
# Define the layers
x = layers.Conv2D(8, 3, activation='relu')(inputs)
x = layers.MaxPooling2D(2)(x)
x = layers.Conv2D(16, 3, activation='relu')(x)
x = layers.MaxPooling2D(2)(x)
x=layers.Flatten()(x)
x = layers.Dense(128, activation='relu')(x)
output_x = layers.Dense(1, activation = 'linear', name = "y1_output")(x)
model = Model(inputs = inputs, outputs = output_x)
model.summary()
What can I do to improve my loss significantly?
I have tried different Activation functions and different optimizers.
New contributor
Shans Second is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.