0

I am trying to perform pixel-wise normalization, but I dont understand the concept or how to implement it.

I have the MNIST Fashion data set, I have performed mean normalization on all the 1024 images.

# Assuming all images are the same size, get dimensions of the first image
w = 28
h = 28

N=len(data)
print(N)

print('data shape',data.shape)

# Create a numpy array of floats to store the average (assume RGB images)
arr=np.zeros((1,h,w),np.float)

print('arr size:', arr.shape)
# print(arr)

# Build up average pixel intensities, casting each image as an array of floats
for im in data:
    #print(type(im))
    imarr = np.array(np.mean(im.asnumpy(), axis=(0)), dtype=np.float) 
    arr= arr + imarr / N

# Round values in array and cast as 8-bit integer
arr=np.array(np.round(arr),dtype=np.uint8)

I need to subtract a sample image from the dataset from the arr

Dharman
  • 30,962
  • 25
  • 85
  • 135
Oscar Rangel
  • 848
  • 1
  • 10
  • 18

1 Answers1

0
batch_mean = mx.ndarray.sum(batch,axis=0)/(batch.shape[0])
Dharman
  • 30,962
  • 25
  • 85
  • 135
james
  • 1