How to extract train and validation sets in Keras?

前端 未结 1 1014
余生分开走
余生分开走 2021-01-23 06:11

I implement a neural net in keras, with the following structure:

model = Sequential([... layers ...])
model.compile(optimizer=..., loss=...)
hist=mo         


        
1条回答
  •  醉话见心
    2021-01-23 06:56

    Keras splits the dataset at

    split_at = int(x[0].shape * (1-validation_split))
    

    into the train and validation part. So if you have n samples, the first int(n*(1-validation_split)) samples will be the training sample, the remainder is the validation set.

    If you want to have more control, you can split the dataset yourself and pass the validation dataset with the parameter validation_data:

    model.fit(train_x, train_y, …, validation_data=(validation_x, validation_y))
    

    0 讨论(0)
提交回复
热议问题