# How to perform Denormalization Calculation on model output

I have a model which take input of shape [1, 128] and inputs are range of numbers between say [0…100]. It returns a mx.nd.array of shape [1, 128] which are floating point values.

Now I need to perform some denormalization based on some statistics for each 128 input numbers for each output values. Each number has a mean and std associated , and I need to change the output of the model with the calculation like below …

here in the for loop in hybrid_forward, I need to alter the value of model output based on the mean and std value of corresponding input ( coming from a json file)

``````class Joined(mx.gluon.HybridBlock):
def __init__(self, model_1):
super(Joined, self).__init__()
self.model_1 = model_1
f = open('./norm.json')
# Create the dictionary stats for each numbers in the range. This is static
self.stats = {}
for key, value in _mean_std_params.items():
tokens = value['tokens']
std = value['std']
mean = value['mean']
for token in tokens:
self.stats[token] = (std, mean)

def hybrid_forward(self, F, x):
model_1_out = self.model_1(x)
model_1_out = model_1_out.squeeze()
input_lf = x.squeeze()
denormalized_array= []

for token_id, value in zip(input_lf, model_1_out):
# perform de-norm
rounded_value = F.round(value * self.stats[token_id][0] + self.stats[token_id][1])
denormalized_array.append(rounded_value)

model_2_out = F.stack(*denormalized_array)

return model_2_out
``````

but for mx.gluon.HybridBlock this seems not working as it says.

``````    rounded_value = F.round(dur * self.stats[token_id][0] + self.stats[token_id][1])
TypeError: unhashable type: 'Symbol'
``````

Any idea how to solve this problem