张量流中张量的标准化

时间:2017-02-06 05:53:38

标签: python tensorflow scikit-learn standardized

我有以下函数来将输入/输出标准化/反转为值列表。现在我想将它反演应用于张量,这样我就可以用“实际”单位写出损失值。显然,这不能直接应用于张量。当然这可以通过手动计算来完成,但我想知道是否有这样做的框架方法?我找到tf.nn.l2_normalize但不确定我需要什么,以及如何反转它。

def _transform(self, x_in, y_in):
    print(x_in, y_in)
    if not hasattr(self, "x_scaler"):
        self.x_scaler = preprocessing.StandardScaler().fit(_sample_feature_matrix(x_in))
        self.y_scaler = preprocessing.StandardScaler().fit(_sample_feature_matrix(y_in))
    x_std = self.x_scaler.transform(_sample_feature_matrix(x_in))
    y_std = self.y_scaler.transform(_sample_feature_matrix(y_in))
    return x_std, y_std

def _inverse_y(self, y_std):
   return self.y_scaler.inverse_transform(_sample_feature_matrix(y_std)) 

"""Converts a list of samples with a single feature value in each to  n_samples, n_features) matrix suitable for sklearn"""
def _sample_feature_matrix(in_list):
    return np.array(in_list).reshape(-1, 1)

0 个答案:

没有答案
相关问题