最近,我正在阅读《 SEGAN:语音增强生成对抗网络》一文。当我尝试重复实验时,我遇到了一个问题。在generator.py中,make_z是什么意思?这部分是做什么的? 类Generator(object):
def __init__(self, segan):
self.segan = segan
def __call__(self, noisy_w, is_ref, spk=None):
""" Build the graph propagating (noisy_w) --> x
On first pass will make variables.
"""
segan = self.segan
def make_z(shape, mean=0., std=1., name='z'):
if is_ref:
with tf.variable_scope(name) as scope:
z_init = tf.random_normal_initializer(mean=mean, stddev=std)
z = tf.get_variable("z", shape,
initializer=z_init,
trainable=False
)
if z.device != "/device:GPU:0":
# this has to be created into gpu0
print('z.device is {}'.format(z.device))
assert False
else:
z = tf.random_normal(shape, mean=mean, stddev=std,
name=name, dtype=tf.float32)
return z