1

我试图通过给生成器一个边缘批次来改进 DCGAN。我对数组的尺寸有疑问。我希望我的图像边缘数组具有与np.random.randn(64, 128)

这是我的一些代码:

def load_dataset():
  """
  """
  (X, _), (_, _) = cifar10.load_data()
  #X = np.expand_dims(X, axis=-1).astype('float32')
  X = (X - 127.5) / 127.5
  return X.astype('float32')

def rgb2edge(img):
  bw = cv2.Sobel(rgb2gray(img), cv2.CV_64F, 1, 0)
  return bw
c = rgb2edge(X[1000])
for i in range(64):
  x = rgb2edge(X[i])
  np.concatenate((c,x))

def generate_batch_fake(generator, n_latent_dim, n_samples):
  """
  """
  x_input = np.random.randn(n_samples, n_latent_dim) #Here is where I want to put the array "c"
  X = generator.predict(x_input)
  y = np.zeros((n_samples, 1))
  return X, y

如您所见,我的数组“c”的大小为 (64,32,32)

所以我尝试的错误如下:

“层序_10 的输入 0 与层不兼容:输入形状的预期轴 -1 具有值 128,但接收到形状为 [32, 32] 的输入。”

任何关于如何改变尺寸的建议都会很棒!

4

0 回答 0