TensorflowでseqGANを作成するだけです。TensorflowでRNNの変数を共有する方法
しかし変数を共有することはできません。
私はどのように再利用することを私に教えてください...以下のよう
import tensorflow as tf
def discriminator(x, args, name, reuse=False):
with tf.variable_scope(name, reuse=reuse) as scope:
print(tf.contrib.framework.get_name_scope())
with tf.variable_scope(name+"RNN", reuse=reuse) as scope:
cell_ = tf.contrib.rnn.GRUCell(args.dis_rnn_size, reuse=reuse)
rnn_outputs, _= tf.nn.dynamic_rnn(cell_, x, initial_state=cell_.zero_state(batch_size=args.batch_size, dtype=tf.float32), dtype=tf.float32)
with tf.variable_scope(name+"Dense", reuse=reuse) as scope:
logits = tf.layers.dense(rnn_outputs[:,-1,:], 1, activation=tf.nn.sigmoid, reuse=reuse)
return logits
discriminator(fake, args, "D_", reuse=False) #printed D_
discriminator(real, args, "D_", reuse=True) #printed D_1
をコード目指し弁別を書きました。