tf.compat.v1.disable_eager_execution() with tf.data.dateset

416 views Asked by At

I am using tensorflow 2.2. I have two numpy arrays (features and labels) that I pass to tf.data.dataset.from_tensor_slices():

train_dataset = tf.data.Dataset.from_tensors(feature_train_slice, label_train_slice).shuffle(buffer_size).reapeat()

test_dataset = tf.data.Dataset.from_tensors(feature_test_slice, label_test_slice).shuffle(buffer_size).repeat()

I am trying to pass this data to my model.fit():

history = self.model.fit(ds_train,
                            steps_per_epoch=int(train_steps / (batch_size)),
                            verbose=1,
                            epochs=epochs,
                            callbacks=self.call_back(),
                            use_multiprocessing=True,
                            validation_data = test_dataset,
                            validation_steps = int(validation_steps / (batch_size))
                            )

I used the

tf.compat.v1.disable_eager_execution()

at the beginning of my code. If I comment it out, the training starts with no issues, but the training I realize is slower (each step takes 2 seconds on 2080TI). If I leave it each step is about 1.2 seconds. However, the program never passes the line

train_dataset = tf.data.Dataset.from_tensors(feature_train_slice, label_train_slice).shuffle().reapeat()

I left the program for more than 30 minutes and while about 60GB (my ram is 64GB) is consumed, the program does not seem to do anything. Has anyone seen this before? any help is welcome.

1

There are 1 answers

0
xyz On

repeat() must come instead of reapeat().