Keras ImageDataGenerator rescale values to [-0.5, 0.5]

ImageDataGenerator class from Keras has parameter rescale which changes pixel value from [0, 255] to [0, 1]. Is it possible to change it to [-0.5, 0.5]?

Thank you for your answers!

Upvotes: 1

Views: 423

Answers (1)

jgorostegui
jgorostegui

Reputation: 1310

As it is specified in the documentation:

rescale: rescaling factor. Defaults to None. If None or 0, no rescaling is applied, otherwise we multiply the data by the value provided (after applying all other transformations).

So it is not possible to achieve [-0.5, 0.5] with this parameter, but you could achieve [0, 1] range with 1/255. factor.

For rescaling the images to [-0.5, 0.5] range you could do interp each image after data agumentation:

np.interp(image, (0, 255), (-0.5, 0.5))  

Upvotes: 1

Related Questions