<BatchDataset shapes: ((None, 32, 32, 3), (None,)), types: (tf.float32, tf.int64)>

Hello community,

I am new in TensorFlow. I am trying to execute this open-source code. However, I am getting this error while preparing the dataset;

def prepare_dataset(images, labels):
    images_placeholder = tf.compat.v1.placeholder(tf.float32, images.shape)
    labels_placeholder = tf.compat.v1.placeholder(tf.int64, labels.shape)
    dataset = tf.data.Dataset.from_tensor_slices((images_placeholder, labels_placeholder))
    dataset = dataset.shuffle(buffer_size=10000, seed=config['random_seed']).repeat()

    if config['augment_dataset']:
        dataset = dataset.map(
            make_data_augmentation_fn(
                standardization=config['augment_standardization'],
                flip=config['augment_flip'],
                padding=config['augment_padding'],
                is_training=True))

   dataset = dataset.batch(batch_size=50)
    print(dataset,"this is batch")
    # iterator = tf.compat.v1.dataset.make_initializable_iterator()
    iterator = tf.compat.v1.data.make_initializable_iterator(dataset)
    return (images_placeholder, labels_placeholder), dataset, iterator

clean_placeholder, clean_train_dataset_batched, clean_training_iterator = prepare_dataset(clean_train_images, clean_train_labels)

print(clean_train_dataset_batched)
poisoned_placeholder, _, poisoned_training_iterator = prepare_dataset(poisoned_train_images, poisoned_train_labels)
if len(poisoned_train_indices) > 0:
    poisoned_only_placeholder, _, poisoned_only_training_iterator = prepare_dataset(poisoned_only_train_images, poisoned_only_train_labels)
    poisoned_no_trigger_placeholder, _, poisoned_no_trigger_training_iterator = prepare_dataset(poisoned_no_trigger_train_images, poisoned_no_trigger_train_labels)

handle = tf.compat.v1.placeholder(tf.string, shape=[])

# input_iterator = tf.compat.v1.data.Iterator.from_string_handle(handle,clean_train_dataset_batched.output_types,
#                                                      clean_train_dataset_batched.output_shapes)

The error is batches are not append

<BatchDataset shapes: ((None, 32, 32, 3), (None,)), types: (tf.float32, tf.int64)> this is batch
<BatchDataset shapes: ((None, 32, 32, 3), (None,)), types: (tf.float32, tf.int64)>
<BatchDataset shapes: ((None, 32, 32, 3), (None,)), types: (tf.float32, tf.int64)> this is batch

Can anyone help me in solving this error? Appreciate your time and effort

Hi @Iram_Arshad, I have tried to do the batch dataset using the Tensorflow 2.x and have made the batch dataset without any issue. please refer to this gist for working code example. Thank You.

Post is from 2021 it seems