转载:https://blog.csdn.net/gaoyueace/article/details/79079068

 例如:

#在名字为ae的命名空间内创建变量
with tf.variable_scope('ae'):
     Y_pred, Y_pred_modi = self.ae_u(X)
with tf.variable_scope('dis'):
     XY_real_pair = self.dis(X, Y)
with tf.variable_scope('dis',reuse=True):
     XY_fake_pair = self.dis(X, Y_pred)
with tf.variable_scope('dis',reuse=True):
     XY_fake_intep = self.dis(X, interpolates)

ae_var = [var for var in tf.trainable_variables() if var.name.startswith('ae')]
dis_var = [var for var in tf.trainable_variables() if var.name.startswith('dis')]
ae_g_optim = tf.train.AdamOptimizer(learning_rate=lr, beta1=0.9, beta2=0.999, epsilon=1e-8).minimize(ae_gan_g_loss, var_list=ae_var)
dis_optim = tf.train.AdamOptimizer(learning_rate=lr,beta1=0.9,beta2=0.999,epsilon=1e-8).minimize(gan_d_loss_gp,var_list=dis_var)

  

  

posted on 2018-06-25 19:25  chamie  阅读(233)  评论(0编辑  收藏  举报