def __init__(self, latent_dim, img_shape): # 继承父类特性 super(Generator, self).__init__() self.img_shape = img_shape # def block(in_feat, out_feat, normalize=True): layers = [nn.Linear(in_feat, out_feat)] if normalize: layers.append(nn.BatchNorm1d(out_feat, 0.8)) layers.append(nn.LeakyReLU(0.2, inplace=True)) return layers # self.model = nn.Sequential( *block(latent_dim, 128, normalize=False), *block(128, 256), *block(256, 512), *block(512, 1024), nn.Linear(1024, int(np.prod(img_shape))), nn.Tanh() )
时间: 2023-06-03 20:07:01 浏览: 125
SVD.rar_SVD_decomposition_svd java_svd...java
这是一个Python中的类构造函数,函数名为__init__,该函数包含两个参数:latent_dim和img_shape。其中,latent_dim表示生成模型中的噪声维度,img_shape表示生成的图像的形状。
阅读全文