Solved by braindotai in post #5 
              
              
                Try to normalize the dataset as below so that for each example the minimum and maximum value is 0.0 and 1.0 respectively. 
image = (image - image.min())/(image.max() - image.min())