Unable Train on Tpu Google Colab InternalError: 9 root error(s) found

Viewed 116
BATCH SIZE = 64
HEIGHT ,WIDTH = 124,124

Train_data set   = 14906 6 classes.
Validation_datat =  3726 6 classes.

with strategy.scope():
  model = create_model()
  model = complile_model(model,lr=0.0001)
  callbacks = create_callbacks()
epochs = 5
steps_per_epoch  = 14906//BATCH_SIZE
validation_steps = 3726//BATCH_SIZE

history = model.fit(train_dataset,
                    epochs=epochs,
                    steps_per_epoch=steps_per_epoch,
                    validation_data=validation_dataset, 
                    validation_steps=validation_steps)

I am trying to train it on TPU provided by google collab but unable to do so kindly help me regarding this. Have attached the screen-shot

enter image description here

2 Answers

Dataset must repeat():

def get_dataset(filenames, batch_size):
    dataset = (
        tf.data.TFRecordDataset(filenames, num_parallel_reads=AUTOTUNE)
        .map(parse_tfrecord_fn, num_parallel_calls=AUTOTUNE)
        .map(prepare_sample, num_parallel_calls=AUTOTUNE)
        .repeat()
        .shuffle(batch_size * 10)
        .batch(batch_size)
        .prefetch(AUTOTUNE)
    )
    return dataset

Since ImageDataGenerator also uses PyFunction under the hood, it is incompatible with TPUs. Instead, you have to use the tf.data API to load images. This tutorial explains how to do it.

Related