目前运行keras模型,为了分析算法参数变化的最终输出,我尝试在循环内运行模型,并使用所需输出(损失)更新 Dataframe
请参阅代码。
输出包含列名的空 Dataframe
epochs = [1,5,10,15,20,25,30]
batch_sizes = [64,128,256,512]
modeldata = pd.DataFrame()
for e in epochs:
modeldata['Epochs'] = e
for bs in batch_sizes:
modeldata['Batch Size'] = bs
training = mod_nvp.fit(
x_train, y_train,
batch_size = bs,
epochs = e,
validation_split = 0.2,
verbose = 0
)
y_pred = mod_nvp.predict(x_test, verbose = 0)
modeldata['Loss'] = custom_loss_nvp1(y_test,y_pred)
#modeldata['Training Loss'] = np.sum(training.history['loss'])
#modeldata['Test Loss'] = np.sum(training.history['val_loss'])
print('current running epoch',e,'with batchsize',bs)
`
1条答案
按热度按时间xhv8bpkk1#
我对代码做了这样的编辑,它完成了所需的工作