我正在尝试实现一个 cDCGAN。我的数据集有 2350 个 num_classes,batch_size 是 100,图像大小是 64(rows=64,cols=64,channels=1),z_shape 是 100 我的值占位符如下。
self.phX = tf.placeholder(tf.float32, [None, self.rows, self.cols, self.channels])
self.phZ = tf.placeholder(tf.float32, [None, self.z_shape])
self.phY_g = tf.placeholder(tf.float32, [None, self.num_classes])
self.phY_d = tf.placeholder(tf.float32, shape=(None, self.rows, self.cols, self.num_classes))
我正在为训练循环中的 phY_g 和 phY_d 加载一批图像、noise_Z 和标签(一个热编码),如下所示。
# Get a random batch of images and labels. This gives 100 images of shape [100,4096] and 100 labels of shape [100,2350]
train_images, train_labels = self.sess.run([self.image_batch, self.label_batch])
# Real image input for Real Discriminator,
# Reshape images to pass to D
batch_X = train_images.reshape((self.batch_size, self.rows, self.cols, self.channels))
batch_X = batch_X * 2 - 1
# Z noise for Generator
batch_Z = np.random.uniform(-1, 1, (self.batch_size, self.z_shape)) # Shape is [?, 100]
# Label input for Generator
batch_Y_g = train_labels
batch_Y_g = batch_Y_g.reshape([self.batch_size, self.num_classes])
# Label input for Discriminator
batch_Y_d = train_labels
batch_Y_d = batch_Y_d.reshape([self.batch_size, self.rows, self.cols, self.num_classes])
一切正常,但对于 batch_Y_d 我收到错误“ValueError:无法将大小为 235000 的数组重新整形为形状(100,64,64,2350)”
如何根据占位符形状重塑它?