0

AttributeError: 'numpy.ndarray' object has no attribute 'map'`

I don't know shape of tensorflow datasets. So might be it's not compatible with my own datasets.

i got the code from KERAS https://keras.io/examples/generative/ddpm/. i want to use own datasets instead load oxford_flowers102 from tensorflow datasets.

dataset_name = "oxford_flowers102"
splits = ["train"] 

Load the dataset

(ds,) = tfds.load(dataset_name, split=splits, with_info=False, shuffle_files=True)`

My datasets was 100 images with 2 clases, and saved in my gDrive, and i want split with sklearn library

print('X Train ; ', len(X_train))
print(X_train.shape)
print('X Test ; ', len(X_test))
print(X_test.shape)
print('..............')

print('Y Train ; ', len(y_train))
print(y_train.shape)
print('Y Test ; ', len(y_test))
print(y_test.shape)

X Train ; 766 (766, 224, 224, 3) X Test ; 256 (256, 224, 224, 3) .............. Y Train ; 766 (766,) Y Test ; 256 (256,)

i got error when :

train_ds = (
    X_train.map(train_preprocessing, num_parallel_calls=tf.data.AUTOTUNE)
    .batch(batch_size, drop_remainder=True)
    .shuffle(batch_size * 2)
    .prefetch(tf.data.AUTOTUNE)
)

` 1 train_ds = ( ----> 2 X_train.map(train_preprocessing, num_parallel_calls=tf.data.AUTOTUNE) 3 .batch(batch_size, drop_remainder=True) 4 .shuffle(batch_size * 2) 5 .prefetch(tf.data.AUTOTUNE)

AttributeError: 'numpy.ndarray' object has no attribute 'map'`

I don't know shape of tensorflow datasets. So might be it's not compatible with my own datasets.

0 Answers0