Dataset : repeat()

Hello,

I am training a model but I am facing some issues regarding the number of epoch and batches. Then, I added the repeat() function but it doesn’t change anything and I am still getting an error message.
Do you have an idea how to solve this? I think the amount of data should be enough, doesn’t it?

Here is the code:

BATCH_SIZE = 500
coeff=0.2
N_VALIDATION = int(coeff*len(df))
N_TRAIN = int((1-coeff)*len(df))
BUFFER_SIZE= N_TRAIN
STEPS_PER_EPOCH = 1 #int(N_TRAIN//BATCH_SIZE)
 
inputs, labels=split_window(df)
 
ds=tf.data.Dataset.from_tensor_slices((inputs, labels))
packed_ds=ds.shuffle(BUFFER_SIZE).repeat(3).batch(BATCH_SIZE, drop_remainder=True)#.prefetch(tf.data.AUTOTUNE)
 
validate_ds = packed_ds.take(N_VALIDATION).cache()
train_ds = packed_ds.skip(N_VALIDATION).take(N_TRAIN).cache()
 
def compile_and_fit(model, name, optimizer=None, max_epochs=1000):
  if optimizer is None:
    optimizer = get_optimizer()
  model.compile(optimizer=optimizer,
                loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
                metrics=[
                  tf.keras.losses.BinaryCrossentropy(
                      from_logits=True, name='binary_crossentropy'),
                  'accuracy'])
 
  history = model.fit(
    train_ds,
    steps_per_epoch = STEPS_PER_EPOCH,
    epochs=max_epochs,
    validation_data=validate_ds,
    callbacks=get_callbacks(name),
    verbose=0)
 
  model.summary()
 
  return history

This is the error message:

Blockquote

0
Input shape: (1462161, 30, 1)
Target shape: (1462161, 30, 1)
0
2022-08-11 03:58:06.466184: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1666] function cupti_interface_->Subscribe( &subscriber_, (CUpti_CallbackFunc)ApiCallback, this)failed with error CUPTI could not be loaded or symbol could not be found.
2022-08-11 03:58:06.811542: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1757] function cupti_interface_->Finalize()failed with error CUPTI could not be loaded or symbol could not be found.
WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least steps_per_epoch * epochs batches (in this case, 1000 batches). You may need to use the repeat() function when building your dataset.
Expect x to be a non-empty array or dataset.

Blockquote

Thank you in advance,

Laurick

I just want to says that order is ds.shuffle(…).repeat().batch(…). At least for TensorFlow 2.1.0.

try
STEPS_PER_EPOCH = 50
ds.shuffle(BUFFER_SIZE).batch(BATCH_SIZE, drop_remainder=True).repeat()