Skip to content Skip to sidebar Skip to footer

Keras List Of Numpy Arrays Not The Size Model Expected

I am having trouble finding the correct way of passing multiple inputs to a model. The model has 2 inputs noise image of shape (256, 256, 3) input image of shape (256, 256, 3) a

Solution 1:

When you have multiple inputs/outputs you should pass them as a list of numpy arrays. So your second approach is correct but you have forgotten to convert the lists to numpy arrays in your second approach:

yield ([np.array(noises), np.array(bw_images)], np.array(g_y))

A more verbose approach to make sure everything is correct, is to choose names for the input and output layers. Example:

input_1 = layers.Input(# other args, name='input_1')
input_2 = layers.Input(# other args, name='input_2')

Then, use those names like this in your generator function:

yield ({'input_1': np.array(noises), 'input_2': np.array(bw_images)}, {'output': np.array(g_y)})

By doing so, you are making sure that the mapping is done correctly.

Post a Comment for "Keras List Of Numpy Arrays Not The Size Model Expected"