CNN data tips

I have a CNN which I want to throw in arrays of data of float. Should I load it as text and convert it to float? Or use some other existing method with tensorflow? Can anybody give me some suggestions?

Input data to a CNN should be numeric. If data is present in an external directory, consider using tf.keras.utils.image_dataset_from_directory

I’ve used this before on images! But can this function be used on a numpy array? Because for my specific application, I want to directly input an array for training!

Model.fit args section tells you all supported formats for x (numpy array is one of them).

just by looking at the documents by the tf.keras.utils.image_dataset_from_directory , I only see that it supports image format. Can you show me how with the link that you posted above? Much thanks !

These are the points I’m referring to under x for Model.fit:

  • A Numpy array (or array-like), or a list of arrays (in case the model has multiple inputs).
  • A TensorFlow tensor, or a list of tensors (in case the model has multiple inputs).

You can directly pass arrays to the fit method.

Gotcha! So what you mean is that I can preprocess my data using numpy tools, arrange the labels then directly train? Just to make sure!

You are correct.

Tensorflow also supports scalable input pipelines via Dataset which is covered in MLOps

1 Like