YONG BAGJNS
YONG BAGJNS

Reputation: 531

keras validation_data with multiple input

I try to use validation_data method, but have a problem

model.fit([X['macd_train'], X['rsi_train'],X['ema_train']],
           Y['train'],
           sample_weight=sample_weight,
           validation_data=([X['macd_valid'],
                             X['rsi_valid'],
                             X['ema_valid']],
                             Y['valid']),
           epochs=nb_epochs,
           batch_size=512,
           verbose=True,
           callbacks=callbacks)

I get an error :

ValueError: The model expects 3  arrays, but only received one array. Found: array with shape (127, 100, 8)

My code can run properly if I use validation_data=None

Here is my variables information

X['macd_train'].shape, X['macd_valid'].shape
(507, 100, 2), (127, 100, 2)

X['rsi_train'].shape, X['rsi_valid'].shape
(507, 100, 1), (127, 100, 1)

X['ema_train'].shape, X['ema_valid'].shape
(507, 100, 6), (127, 100, 6)

Y['train'].shape, Y['valid'].shape
(507, 1), (127, 1)

Upvotes: 8

Views: 2754

Answers (1)

Coding thermodynamist
Coding thermodynamist

Reputation: 1373

model.fit() takes as first argument the data input and as the second one the data output. You attempt to do that by using [X['macd_train'], X['rsi_train'], X['ema_train']]

However, you are not concatenating your data but only increasing the dimension of your array. You should use the numpy.concatenate() to have control over your concatenation over the proper axis.

Upvotes: 2

Related Questions