Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

测试集的问题 #3

Open
barryhunt opened this issue Jan 21, 2022 · 1 comment
Open

测试集的问题 #3

barryhunt opened this issue Jan 21, 2022 · 1 comment

Comments

@barryhunt
Copy link

model.fit(trainInputs, array(trainOutputs).astype(int), batch_size=32, epochs=1000,shuffle=True,validation_data=(testInputs, array(testOutputs).astype(int)),callbacks=[reduce_lr,acc_stop])
测试数据同时作为验证集,会导致测试准确率比实际高出很多,这里会有一些问题存在

@timmmGZ
Copy link
Owner

timmmGZ commented Feb 24, 2022

model.fit(trainInputs, array(trainOutputs).astype(int), batch_size=32, epochs=1000,shuffle=True,validation_data=(testInputs, array(testOutputs).astype(int)),callbacks=[reduce_lr,acc_stop]) 测试数据同时作为验证集,会导致测试准确率比实际高出很多,这里会有一些问题存在

并不会,验证集本身用作评估模型而不会影响模型训练,它不参与权值更新。间接的影响可以通过根据验证集的loss或者acc的变动来调整超参数如learning rate(脚本里的ReduceLROnPlateau()是个例子),但影响微弱(相对于众多任务)。其实你稍微删除了fit里面的验证集就知道结果了,此小型任务拿测试集来做验证集仅仅为了监控训练时的test acc从而方便研究其中规律。
或者你换个方式,删了验证集,写个loop,然后每一个epoch都model.predict(testInputs)一次。这是我最开始的做法,那时50%spilt率的测试集准确率一样90+,只不过loop写法麻烦点。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants