调用model.fit()
时,如果参数shuffle
和validation_split
分别设置为True
和.25
,则预留用于验证的数据是否始终相同,还是每个历元后都会更改验证数据?
model.fit(train_x,
train_y,
batch_size = 32,
epochs = 1000,
verbose = 1,
shuffle = True,
validation_split = .25)
每个历元的验证数据将保持相同。如果你停止代码并重新启动它,分割将会改变。
您将拥有相同的验证数据(主数据集的最后25%)。您可以使用下面的代码进行测试:
import numpy as np
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import *
trainX = np.zeros((1000, 1))
trainy = np.array(np.arange(10000)).reshape(1000, 10)
model = Sequential()
model.add(Input((1, )))
model.add(Dense(10))
opt = keras.optimizers.Adam(0)
model.compile(opt, 'mae')
model.fit(trainX, trainy, epochs = 10, shuffle = True, validation_split = 0.2)