Training and validation accuracy and loss not changing?
Hi @WenTheProgrammer, 
Could you please provide the dataset along with the pre-processing steps, so that we can replicate the issue from our end. Thank you!   Hi @synandi,
Attached dataset is a tiny subset of my actual dataset. I was able to recreate my issue using this dataset by splitting it randomly for training (70%) and validation (30%). I did not have any preprocessing steps other than normalization. 
[Sample Data.zip](https://github.com/tensorflow/tensorflow/files/11471347/Sample.Data.zip)

 Check this code once. 

batch_size = 1
num_epochs = 1000
model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(16, (5,2), activation='relu', input_shape=(252,4,1)),
    tf.keras.layers.Conv2D(32, (4,2), activation='relu'),
    tf.keras.layers.Conv2D(64, (3,2), activation='relu'),
    tf.keras.layers.Conv2D(128, (2,1), activation='relu'),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(32, activation='relu'),
    tf.keras.layers.Dense(16, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])

opt = Adam(learning_rate=0.001)
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])


history = model.fit(
    data_generator(x_train_list, y_train_list, batch_size),
    batch_size=batch_size,
    epochs=num_epochs,
    steps_per_epoch=len(x_train_list)//batch_size,
    validation_data=(x_val, y_val))

I am assuming there is an incorrect definition of input_shape = (242,4,1) but correct input_shape = (4, 252, 1) should be in my view because the First dimension represents the number of channels, and channels should be 4 instead of 252. Also, Order of the dimension is heights, width, channels. All the others look pretty good But my input image size is 252x4. I don't see how transposing the images would make a difference, Maybe my input shape should be (1,252,4) since my images are grayscale? @WenTheProgrammer,
Unfortunately with the code provided above, we were not able to analyse the  issue where it went wrong. Could you please provide the complete standalone code or the colab gist which helps us to debug the issue in an effective way. Thank you!  This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. Hi @tilakrayal,

Here it is:

```
import os
import glob
import numpy as np
import random
import tensorflow as tf
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping
from tensorflow.keras.optimizers import Adam

os.chdir(r'Sample Data')

# Get x and y list
x_list = glob.glob("*.npy")[:len(glob.glob("*.npy")) // 2]
y_list = glob.glob("*.npy")[len(glob.glob("*.npy")) // 2:]

# Calculate the number of elements for each segment
len_train = int(len(x_list) * 0.7)
len_val = int(len(x_list) * 0.2)

# Randomly select elements from the original list for each segment
indices_random = random.sample(range(len(x_list)), len(x_list))

x_train_list = [x_list[i] for i in indices_random[:len_train]]
x_val_list = [x_list[i] for i in indices_random[len_train:len_train+len_val]]
x_test_list = [x_list[i] for i in indices_random[len_train+len_val:]]

y_train_list = [y_list[i] for i in indices_random[:len_train]]
y_val_list = [y_list[i] for i in indices_random[len_train:len_train+len_val]]
y_test_list = [y_list[i] for i in indices_random[len_train+len_val:]]

batch_x = []
batch_y = []

for x_file, y_file in zip(x_val_list, y_val_list):
    x = np.load(x_file)
    batch_x.append(x)
    y = np.load(y_file)
    batch_y.append(y)
x_val = np.stack(batch_x, axis=0)
y_val = np.array(batch_y)

def data_generator(x_train_list, y_train_list, batch_size):
    num_samples = len(x_train_list)
    while True:
        for i in range(0, num_samples, batch_size):
            batch_x_files = x_train_list[i:i+batch_size]
            batch_y_files = y_train_list[i:i+batch_size]
            batch_x = []
            batch_y = []
            for x_file, y_file in zip(batch_x_files, batch_y_files):
                x = np.load(x_file)
                batch_x.append(x)
                y = np.load(y_file)
                batch_y.append(y)
            batch_x = np.stack(batch_x, axis=0)
            batch_y = np.array(batch_y)
            yield batch_x, batch_y

batch_size = 1
num_epochs = 1000

model = tf.keras.models.Sequential([

    tf.keras.layers.Conv2D(16, (5, 2), activation='relu', input_shape=(np.load(x_train_list[0]).shape[0],np.load(x_train_list[0]).shape[1], 1)),
    tf.keras.layers.Conv2D(32, (4,2), activation='relu'),
    tf.keras.layers.Conv2D(64, (3,2), activation='relu'),
    tf.keras.layers.Conv2D(128, (2,1), activation='relu'),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(32, activation='relu'),
    tf.keras.layers.Dense(16, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])

opt = Adam(learning_rate=0.001)

# Compile the model
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])

# Define the callbacks to save the best model and early stopping
checkpoint_callback = ModelCheckpoint("best_model_weights.h5", save_best_only=True, monitor='val_accuracy', mode='max')
early_stop_callback = EarlyStopping(monitor='val_accuracy', patience=num_epochs*0.5)

# Train the model
history = model.fit(
    data_generator(x_train_list, y_train_list, batch_size),
    batch_size=batch_size,
    epochs=num_epochs,
    steps_per_epoch=len(x_train_list)//batch_size,
    validation_data=(x_val, y_val),
    callbacks=[checkpoint_callback, early_stop_callback])

# Save the trained model
model.save_weights('final_model_weights.h5')
``` @WenTheProgrammer,
I tried to execute the mentioned code and it was failing with the different issue. Kindly find the gist of it [here](https://colab.research.google.com/gist/tilakrayal/64e9cead5aa1595b4581d332850d83bb/untitled1222.ipynb) and provide the complete dependencies to analyse the issue in an effective way. Thank you! Hi @tilakrayal,

The error was regarding the "Sample Data" folder location. I have attached my sample data in a zip file above. If you unzip that and use the correct folder address containing all the sample data in your computer for `os.chdir(r'Sample Data')`, the error should disappear. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60555">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60555">No</a>

I am trying to train the following model for a binary classification task:

```
batch_size = 1
num_epochs = 1000
model = tf.keras.models.Sequential([
    tf.keras.layers.Conv2D(16, (5,2), activation='relu', input_shape=(252,4,1)),
    tf.keras.layers.Conv2D(32, (4,2), activation='relu'),
    tf.keras.layers.Conv2D(64, (3,2), activation='relu'),
    tf.keras.layers.Conv2D(128, (2,1), activation='relu'),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(128, activation='relu'),
    tf.keras.layers.Dense(64, activation='relu'),
    tf.keras.layers.Dense(32, activation='relu'),
    tf.keras.layers.Dense(16, activation='relu'),
    tf.keras.layers.Dense(1, activation='sigmoid')
])
opt = Adam(learning_rate=0.001)
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(
    data_generator(x_train_list, y_train_list, batch_size),
    batch_size=batch_size,
    epochs=num_epochs,
    steps_per_epoch=len(x_train_list)//batch_size,
    validation_data=(x_val, y_val))
```
However, for some reason my training and validation accuracy and loss are not changing:
```
Epoch 1/1000
157595/157595 [==============================] - 990s 6ms/step - loss: 0.6960 - accuracy: 0.5215 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 2/1000
157595/157595 [==============================] - 648s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 3/1000
157595/157595 [==============================] - 641s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 4/1000
157595/157595 [==============================] - 662s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 5/1000
157595/157595 [==============================] - 667s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 6/1000
157595/157595 [==============================] - 648s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 7/1000
157595/157595 [==============================] - 651s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 8/1000
157595/157595 [==============================] - 646s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 9/1000
157595/157595 [==============================] - 646s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 10/1000
157595/157595 [==============================] - 645s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 11/1000
157595/157595 [==============================] - 648s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 12/1000
157595/157595 [==============================] - 650s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 13/1000
157595/157595 [==============================] - 653s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 14/1000
157595/157595 [==============================] - 644s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 15/1000
157595/157595 [==============================] - 646s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 16/1000
157595/157595 [==============================] - 645s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 17/1000
157595/157595 [==============================] - 667s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 18/1000
157595/157595 [==============================] - 642s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 19/1000
157595/157595 [==============================] - 683s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 20/1000
157595/157595 [==============================] - 677s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 21/1000
157595/157595 [==============================] - 678s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 22/1000
157595/157595 [==============================] - 669s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 23/1000
157595/157595 [==============================] - 697s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 24/1000
157595/157595 [==============================] - 875s 6ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 25/1000
157595/157595 [==============================] - 971s 6ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 26/1000
157595/157595 [==============================] - 639s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 27/1000
157595/157595 [==============================] - 639s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 28/1000
157595/157595 [==============================] - 638s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
Epoch 29/1000
157595/157595 [==============================] - 649s 4ms/step - loss: 0.6927 - accuracy: 0.5217 - val_loss: 0.6918 - val_accuracy: 0.5283
```
I have tried different optimizers and learning rates but they did not seem to help. Is there something wrong with my model? I know my data is pretty noisy. Thanks for any insights and help!