0

I'm currently trying to design a generator model which take input image and the conditional label concatenated in the image.

The input image is in 3D (including channel), while the label is in 1D (containing idx of the class)

input_image = Input(shape=(row, col, chann))
cond = Input(shape=(1,))

Based on info of Concatenate, I need to reshape cond to be in same shape of input_image. But as far as I found on Keras docs, there's only RepeatVector that repeats 2D tensor into 3D.

How do I replicate the cond input to be in the same shape so I can concatenate it?

Muhamad Iqbal
  • 742
  • 1
  • 4
  • 17

1 Answers1

1

You can combine Reshape and RepeatVector

input_image = Input(shape=(row, col, chann))
cond = Input(shape=(1,))
cond = Reshape((row,col,1))(RepeatVector(row*col)(cond))
concat = Concatenate()([input_image, cond])
lenhhoxung
  • 2,530
  • 2
  • 30
  • 61
  • Then how do you replicate 2D tensor to be 3D tensor? Like replicating one-hot vector to be in shape of image `(row, col)` for concatenating it? – Muhamad Iqbal Mar 21 '19 at 07:19