One-hot 编码到嵌入向量 - BigGAN

数据挖掘 张量流 嵌入
2022-03-12 19:42:15

我试图在 Tensorflow 中复制 BigGAN 架构,但无法理解输入的确切性质。BigGAN 生成器有 2 个输入,噪声z[batch size, 120]从正态分布中提取的元素向量Embedded(y)和大小为 的向量[batch size,128],其中y是类标签向量。BigGAN 架构 128x128 通过查看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)是这些类标签的映射。

  1. 它有哪些功能?
  2. 如何将所有可能的类编码为这种嵌入?
  3. 它是否等同于 tf.keras.layers.Embedding(见这里)?version=stable?
  4. 如果是,是否可以按照此处的说明在 tensorflow 中实现?
0个回答
没有发现任何回复~