I have a 4D array of shape (1948, 60, 2, 3) Which I normalized to a range of [0,1]
a sample of how it looks is below:
original_mat = array([[[ 3.93048840e-05, 7.70215296e-04, 1.13865805e-03], [ 1.11679799e-04, -7.04810066e-04, 1.83552688e-04]])
(x - x_min)/ (x_max - x_min)
predicted = array([[ 0.19302673, -0.03372632, -0.23808828], [ 0.30002626, -0.71888705, 0.71468331]])
I fed this input to a neural network to predict a similar output, after convergence my resultant matrix looked the same and to denormalize it ,I did,
denormed_matrix = predicted*(xmax - xmin) + xmin `denormed_matrix` = [[-0.62747524, -0.72737077, 0.70058271], [-0.39488326, -0.18533665, -1.48910199]],
I expected it to have same order of magnitude values
( e-03 to e-05), but the matrix didn't scale down in magnitude, it had similar values like the normalized one.
- Am I missing any point here?
- Are my calculation correct?
EDIT: CODE for Normalization
### Get min, max value aming all elements for each column x = np.asarray(poseList) x_min = np.min(x, axis=tuple(range(x.ndim-1)), keepdims=1) x_max = np.max(x, axis=tuple(range(x.ndim-1)), keepdims=1) # ### Normalize with those min, max values leveraging broadcasting normalized = (x - x_min)/ (x_max - x_min) normalized = 2.0*normalized - 1.0 # noralizing in the range [-1,1] # print "final_save" In : norm.shape Out: (309, 60, 2, 3) In : x_max Out: array([[[[ 0.10778677, 0.16254221, 0.1198302 ]]]]) In : x_min Out: array([[[[-0.56810854, -0.21604319, -0.37091526]]]])
Code for Denormalization Following this formula(@Marco D.G.): enter image description here
normalized = np.load('/home/normalized.npy') normalized = normalized+ 1 #[a,b] = [-1,1] diff = x_max - x_min numerator = diff * normalized denormalized = (numerator/2.0 ) + x_min