【发布时间】:2021-01-16 00:53:20
【问题描述】:
标题几乎概括了它,我正在尝试实现一个 GAN: 如何使用 pytorch 创建一个在 -1 和 1 之间均匀分布的值的批量 batch_size 的张量?
def create_latent_batch_vectors(batch_size, latent_vector_size, device):
'''
The function creates a random batch of latent vectors with random values
distributed uniformly between -1 and 1.
Finally, it moves the tensor to the given ```device``` (cpu or gpu).
The output should have a shape of [batch_size, latent_vector_size].
'''
# maybe torch.distributions.uniform.Uniform() somehow?
return z.to(device)
谢谢!
【问题讨论】: