私はTensorFlowにフィードしたいイメージの配列を持っています。私は平均の周りに画像を中心に置き、標準偏差を標準化したい。私はthis answerを追跡しましたが、平均をゼロにすることはできません。私はかすかなことを学んでいるので、多分簡単なことがありません。Pythonでのイメージの配列の中心合わせ
私の現在のコードは次のとおり
import numpy as np
# Load pickled data
import pickle
# TODO: Fill this in based on where you saved the training and testing data
training_file = 'train.p'
with open(training_file, mode='rb') as f:
train = pickle.load(f)
X_train, y_train = train['features'], train['labels']
# Let us inspect whether the data is centered.
for ch in range(3):
print("for channel %s mean or clahe data: %s" %(
ch, X_train[:,ch].mean()))
X_norm = np.copy(X_train)
for ch in range(3):
X_norm[:, ch] = (X_norm[:, ch] - X_norm[:,ch].mean())/ X_norm[:, ch].std()
# Let us inspect our new mean.
for ch in range(3):
print("for channel %s new mean for CLAHE data: %s new std: %s" % (
ch, X_norm[:,ch].mean(), X_norm[:,ch].std()))
採取データ・セットが出力とhere
から得ることができる。
for channel 0 mean or clahe data: 88.9090870931
for channel 1 mean or clahe data: 88.2472258708
for channel 2 mean or clahe data: 87.5765175619
for channel 0 new mean for CLAHE data: 8.77830238806 new std: 45.7207148838
for channel 1 new mean for CLAHE data: 8.79695563094 new std: 45.7780456089
for channel 2 new mean for CLAHE data: 8.71418658131 new std: 45.5661789057
私の望ましい結果は、平均値の周りの各チャネルのために持っているであろうゼロと標準偏差は1です。