Two issues–not sure if they are related.
First issue is that when I print out the accuracy using a confusion matrix (46.5%), it is different from the model.fit accuracy (~89%).
All the segments of code using training data:
train_ds = tf.data.Dataset.from_generator(FrameGenerator(subset_paths['train'], n_frames, training=True),
output_signature = output_signature)
# Batch the data
train_ds = train_ds.batch(batch_size)
frames, label = next(iter(train_ds))
history = model.fit(x = train_ds,
epochs = 50,
validation_data = val_ds)
At the same time I am also seeing some errors in the training. I have tried changing the batch size without any success.
Epoch 1/50
17/Unknown 47s 2s/step - accuracy: 0.3868 - loss: 1.77962024-08-07 16:13:27.110801: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
/Users/maycaj/anaconda3/lib/python3.11/contextlib.py:155: UserWarning: Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches. You may need to use the `.repeat()` function when building your dataset.
self.gen.throw(typ, value, traceback)
2024-08-07 16:13:30.584240: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
17/17 ━━━━━━━━━━━━━━━━━━━━ 51s 3s/step - accuracy: 0.3907 - loss: 1.7470 - val_accuracy: 0.6000 - val_loss: 0.6804
Epoch 2/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 0s 3s/step - accuracy: 0.4261 - loss: 0.70892024-08-07 16:14:17.404221: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
17/17 ━━━━━━━━━━━━━━━━━━━━ 47s 3s/step - accuracy: 0.4296 - loss: 0.7084 - val_accuracy: 0.6000 - val_loss: 0.6733
Epoch 3/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5752 - loss: 0.6670 - val_accuracy: 0.3778 - val_loss: 0.7342
Epoch 4/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 0s 2s/step - accuracy: 0.4989 - loss: 0.73222024-08-07 16:15:48.459924: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.5005 - loss: 0.7307 - val_accuracy: 0.6000 - val_loss: 0.6651
Epoch 5/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.5763 - loss: 0.6714 - val_accuracy: 0.6000 - val_loss: 0.7116
Epoch 6/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.6061 - loss: 0.6694 - val_accuracy: 0.6000 - val_loss: 0.9239
Epoch 7/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5772 - loss: 0.7055 - val_accuracy: 0.6000 - val_loss: 0.8254
Epoch 8/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 0s 2s/step - accuracy: 0.4682 - loss: 0.84012024-08-07 16:18:50.161854: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.4659 - loss: 0.8379 - val_accuracy: 0.6000 - val_loss: 0.7225
Epoch 9/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.6680 - loss: 0.6395 - val_accuracy: 0.6000 - val_loss: 0.6922
Epoch 10/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5701 - loss: 0.6770 - val_accuracy: 0.6000 - val_loss: 0.6552
Epoch 11/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6319 - loss: 0.6595 - val_accuracy: 0.6000 - val_loss: 0.9322
Epoch 12/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5416 - loss: 0.6640 - val_accuracy: 0.6000 - val_loss: 0.6799
Epoch 13/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6133 - loss: 0.6387 - val_accuracy: 0.6000 - val_loss: 0.8982
Epoch 14/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.4841 - loss: 0.7464 - val_accuracy: 0.6000 - val_loss: 1.0706
Epoch 15/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5673 - loss: 0.7374 - val_accuracy: 0.6000 - val_loss: 0.7965
Epoch 16/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 0s 2s/step - accuracy: 0.5752 - loss: 0.64622024-08-07 16:24:55.453286: I tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
[[{{node IteratorGetNext}}]]
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5785 - loss: 0.6447 - val_accuracy: 0.6000 - val_loss: 0.8740
Epoch 17/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6149 - loss: 0.6220 - val_accuracy: 0.6000 - val_loss: 0.9858
Epoch 18/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5753 - loss: 0.6361 - val_accuracy: 0.6000 - val_loss: 1.0021
Epoch 19/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6128 - loss: 0.6452 - val_accuracy: 0.6000 - val_loss: 0.7140
Epoch 20/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.7083 - loss: 0.5956 - val_accuracy: 0.6000 - val_loss: 0.6552
Epoch 21/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6937 - loss: 0.6198 - val_accuracy: 0.7333 - val_loss: 0.5785
Epoch 22/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.5830 - loss: 0.6744 - val_accuracy: 0.6000 - val_loss: 0.6864
Epoch 23/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6677 - loss: 0.6101 - val_accuracy: 0.6000 - val_loss: 0.7047
Epoch 24/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6521 - loss: 0.5952 - val_accuracy: 0.6000 - val_loss: 0.7624
Epoch 25/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 50s 3s/step - accuracy: 0.6431 - loss: 0.5888 - val_accuracy: 0.6889 - val_loss: 0.5465
Epoch 26/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 46s 3s/step - accuracy: 0.6694 - loss: 0.5774 - val_accuracy: 0.6000 - val_loss: 0.7985
Epoch 27/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.6879 - loss: 0.6017 - val_accuracy: 0.6667 - val_loss: 0.5805
Epoch 28/50
17/17 ━━━━━━━━━━━━━━━━━━━━ 45s 3s/step - accuracy: 0.8072 - loss: 0.5052 - val_accuracy: 0.6000 - val_loss: 0.9059
Epoch 29/50