我试图在keras上实现VAE,以下是我编写的代码片段。
z_mean = Dense( self.z_dim , init=initialization , activation='linear')(H2)
z_mean = LeakyReLU(alpha=.001)(z_mean)
z_log_var = Dense( self.z_dim,init=initialization , activation='linear')(H2)
z_log_var = LeakyReLU(alpha=.001)(z_log_var)
z = Lambda(self.sampling , output_shape=K.int_shape(z_mean) )([z_mean, z_log_var])
H3 = Dense(input_dim - 1, init=initialization , activation='linear')(z)
现在我编译模型时:
model = Model(input=data_input, output=[xh , z_mean , z_log_var ] )
grads = K.gradients(cost, trainable_vars)
它给了我错误:
的 theano.gradient.DisconnectedInputError:
创建该变量时的Backtrace:
H3 =密集(input_dim - 1,init =初始化,激活='线性')(z)
有谁知道为什么会出现这个错误? 我的猜测是渐变无法从z应用到z_mean和z_log_var