Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 802
YONG BAGJNS Avatar asked Sep 13 '17 11:09

YONG BAGJNS


Video Answer


1 Answers

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.

like image 110
Nathan Avatar answered Nov 15 '22 00:11

Nathan