予測二変量ガウス分布パラメータから地面真理値(x、y)を得る負の対数尤度を最小限にしようとする損失関数を実装しようとしています。 、私はトレーニングをやっているとき二変量ガウス分布の対数尤度における負の値
def tf_2d_normal(self, x, y, mux, muy, sx, sy, rho):
'''
Function that implements the PDF of a 2D normal distribution
params:
x : input x points
y : input y points
mux : mean of the distribution in x
muy : mean of the distribution in y
sx : std dev of the distribution in x
sy : std dev of the distribution in y
rho : Correlation factor of the distribution
'''
# eq 3 in the paper
# and eq 24 & 25 in Graves (2013)
# Calculate (x - mux) and (y-muy)
normx = tf.sub(x, mux)
normy = tf.sub(y, muy)
# Calculate sx*sy
sxsy = tf.mul(sx, sy)
# Calculate the exponential factor
z = tf.square(tf.div(normx, sx)) + tf.square(tf.div(normy, sy)) - 2*tf.div(tf.mul(rho, tf.mul(normx, normy)), sxsy)
negRho = 1 - tf.square(rho)
# Numerator
result = tf.exp(tf.div(-z, 2*negRho))
# Normalization constant
denom = 2 * np.pi * tf.mul(sxsy, tf.sqrt(negRho))
# Final PDF calculation
result = -tf.log(tf.div(result, denom))
return result
、私は減少損失値を見ることができますが、それは過去0未満にうまくいく私はそれがためにする必要があります理解することができます - ここで はコードです - 私はtensorflowでこれを実装しています私たちは「否定的」な可能性を最小限に抑えています。損失の値が減少しても、私は結果を正確に得ることができません。私が損失関数のために書いたコードが正しいかどうかを確認する際に助けてもらえますか?
ニューラルネット(特にRNN)をトレーニングするために望ましい損失の性質もありますか?
Thankss