我试图在 Tensorflow 中复制 BigGAN 架构,但无法理解输入的确切性质。BigGAN 生成器有 2 个输入,噪声z是[batch size, 120]从正态分布中提取的元素向量Embedded(y)和大小为 的向量[batch size,128],其中y是类标签向量。
通过查看tfhub代码示例
# Load BigGAN 128 module.
module = hub.Module('https://tfhub.dev/deepmind/biggan-128/2')
# Sample random noise (z) and ImageNet label (y) inputs.
batch_size = 8
truncation = 0.5 # scalar truncation value in [0.02, 1.0]
z = truncation * tf.random.truncated_normal([batch_size, 120]) # noise sample
y_index = tf.random.uniform([batch_size], maxval=1000, dtype=tf.int32)
y = tf.one_hot(y_index, 1000) # one-hot ImageNet label
# Call BigGAN on a dict of the inputs to generate a batch of images with shape
# [8, 128, 128, 3] and range [-1, 1].
samples = module(dict(y=y, z=z, truncation=truncation))
我的理解是这y是一种单一的形式,Embedded(y)是这些类标签的映射。