def register(self, info_tensor, param_tensor):
self.info_tensor = info_tensor #(128,1)
if self.stddev_fix:
self.param_tensor = param_tensor
mean = K.clip(param_tensor[:, 0].dimshuffle(0, 'x'), self.min, self.max)
std = 1.0
else:
self.param_tensor = param_tensor # 2
mean = K.clip(param_tensor[:, 0].dimshuffle(0, 'x'), self.min, self.max)
# std = K.maximum( param_tensor[:, 1].dimshuffle(0, 'x'), 0)
std = K.sigmoid( param_tensor[:, 1].dimshuffle(0, 'x') )
e = (info_tensor-mean)/(std + K.epsilon())
self.log_Q_c_given_x = \
K.sum(-0.5*np.log(2*np.pi) -K.log(std+K.epsilon()) -0.5*(e**2), axis=1) * self.lmbd
# m = Sequential([ Activation('softmax', input_shape=(self.n,)), Lambda(lambda x: K.log(x), lambda x: x) ])
return K.reshape(self.log_Q_c_given_x, (-1, 1))
评论列表
文章目录