【发布时间】:2020-11-04 02:57:51
【问题描述】:
我正在处理音频分类问题。我正在使用包含 8732 音频的 urbansound8k 数据集。
我知道 kfold 将数据同样分成 k 组。每个组将用于测试,其余的将用于训练。
所以如果 k=4,每个组将包含 2,183 个数据。但是,这个结果与我自己的结果相差甚远
batch_size = 1
num_folds =4
no_epochs = 10
kfold = KFold(n_splits=num_folds, shuffle=False)
for train, test in kfold.split(features, labels):
model = Sequential()
model.add(Dense(1000, activation='relu'))
model.add(Dense(no_classes, activation='softmax'))
model.compile(loss=loss_function,
optimizer=opt,
metrics=['accuracy'])
history = model.fit(features[train], labels[train],
batch_size=batch_size,
epochs=no_epochs,
verbose=verbosity,
validation_split=validation_split,shuffle=False)
此代码在 k=4 时具有以下结果:
-5239 使用批量大小 = 1 时每折
-1048 每折叠,批量大小 = 5
- 524 每折叠,批量大小 = 10
我不明白这两个参数之间的关系:批量大小和折叠中的数据数量。
如果需要,我准备分享我的整个代码。
【问题讨论】:
-
这能回答你的问题吗? What does KFold in python exactly do?
标签: python machine-learning keras deep-learning