При попытке реализовать DCGAN i получаю сообщение об ошибке при попытке использовать мою учебную функцию:Tensorflow ValueError: не может подавать значение формы (40, 24, 24, 4) для тензора u'real_images: 0 ', которое имеет форму' (40, 24, 24, 3) '
ValueError: Cannot feed value of shape (40, 24, 24, 4) for Tensor u'real_images:0', which has shape '(40, 24, 24, 3)'
Эта ошибка возникает при попытке использовать строку:
_,summary_str = self.sess.run([dis_optim, self.dis_sum],feed_dict = {self.inputs: batch_images, self.z: batch_z})
Любые идеи, почему тензоры отличаются? Ниже я прилагаю код, где я считаю, что ошибка заключается:
real_images заполнителя (self.colour_dim является 3):
image_dimension = [self.input_H,self.input_H, self.colour_dim]
self.inputs = tf.placeholder(tf.float32, shape=[self.batch_size] + image_dimension, name='real_images')
сегмента, где происходит ошибка:
for idx in xrange(0, batch_idxs):
batch_files = data[idx * config.batch_size:(idx +1) * config.batch_size]
batch = [getImage(batch_file,resize_h=self.output_H,resize_w=self.output_W) for batch_file in batch_files]
batch_images = np.array(batch).astype(np.float32)
print(batch_images)
batch_z = np.random.uniform(-1, 1, [config.batch_size, self.z_dimension]).astype(np.float32)
# discriminator
_,summary_str = self.sess.run([dis_optim, self.dis_sum],feed_dict = {self.inputs: batch_images, self.z: batch_z})
self.writer.add_summary(summary_str, counter)
В GetImage и Используемые полезные функции:
def imread(path):
return scipy.misc.imread(path).astype(np.float)
def getImage(im_path, resize_h, resize_w):
image = imread(im_path)
return transform(image, resize_h, resize_w)
Спасибо всем!
Работал отлично! Благодаря! – Volken