How to normalize set of images between (-1,1)
i have a dataset on images and i would like to normalize them betwwen (-1,1) before feeding them to NN how can i do that ? 

x=sample
#Normalized Data
normalized = (x-min(x))/(max(x)-min(x))

# Histogram of example data and normalized data
par(mfrow=c(1,2))
hist(x,          breaks=10, xlab="Data",            col="lightblue", main="")
hist(normalized, breaks=10, xlab="Normalized Data", col="lightblue", main="")



i found this code online but it did not solve my problem since  i have image dataset

Assuming your image img_array is an np.array :

normalized_input = (img_array - np.amin(img_array)) / (np.amax(img_array) - np.amin(img_array))


Will normalize your data between 0 and 1.

Then, 2*normalized_input-1 will shift it between -1 and 1

If you want to normalize multiple images, you can make it a function :

def normalize_negative_one(img):
    normalized_input = (img - np.amin(img)) / (np.amax(img) - np.amin(img))
    return 2*normalized_input - 1


Then iterate over a e.g. list, tuple of images called imgs :

for i,img in enumerate(imgs):
    imgs[i] = normalize_negative_one(img)

