入力/出力を値のリストに標準化/反転するために、次の関数があります。ここで、それをテンソルに逆適用して、損失値を「実際の」単位で記述できるようにします。明らかに、これをテンソルに直接適用することはできません。確かにこれは手動計算で行うことができますが、これを行うフレームワークの手段があるのだろうか? 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)