title: Denormalize Tensorflow
body: <p>I would like to denormalize my prediction from neural network. 
  I first normalize my ground truth, and save its std and mean value in a numpy array: </p>
  
  <pre><code>def norm(x):
    return ((x - x.mean()) / x.std())
  
  norm_y_train_n = norm(y_train_n)
  mean_y_train_n = y_train_n.mean
  std_y_train_n = y_train_n.std
  </code></pre>
  
  <p>Then I train my network: </p>
  
  <pre><code>history = model.fit(x_train_n, norm_y_train_n, batch_size=10, epochs=200, validation_split=0.1, shuffle=True, callbacks=[es])
  </code></pre>
  
  <p>I would like to denormalize my data to the original distribution so I can interpret the rmse in a range that makes sense as follows: </p>
  
  <pre><code>def rmse_denorm(y_true, y_pred):
      return backend.sqrt(backend.mean(backend.square((y_pred*std_y_train_n + mean_y_train_n) - (y_true*std_y_train_n+mean_y_train_n))))
  </code></pre>
  
  <p>but I can't, if I try to convert the numpy values to tensor values with tf.convert_to_tensor like this:</p>
  
  <pre><code>def rmse_denorm(y_true, y_pred):
  return backend.sqrt(backend.mean(backend.square((y_pred*tf.convert_to_tensor(std_y_train_n) + tf.convert_to_tensor(mean_y_train_n)) - (y_true*tf.convert_to_tensor(std_y_train_n)+tf.convert_to_tensor(mean_y_train_n)))))
  </code></pre>
  
  <p>I will get this error: </p>
  
  <pre><code>Failed to convert object of type &lt;class 'builtin_function_or_method'&gt; to Tensor. Contents: &lt;built-in method std of numpy.ndarray object at 0x7ff00811aee0&gt;. Consider casting elements to a supported type.
  </code></pre>
  
  <p>and if I want to cast tensor values: </p>
  
  <pre><code> def rmse_denorm(y_true, y_pred):
  return backend.sqrt(backend.mean(backend.square((tf.dtypes.cast(y_pred)*std_y_train_n + mean_y_train_n) - (tf.dtypes.cast(y_true)*std_y_train_n+mean_y_train_n))))
  </code></pre>
  
  <p>I get this error: </p>
  
  <pre><code>TypeError: cast() missing 1 required positional argument: 'dtype'
  </code></pre>
  
  <p>how do I do this? </p>