我有一个网络,该网络具有两个头部和两个不同的输出,我想分别查看其度量/精度。 CNTK的培训师课程有可能吗?现在,我将损失和指标定义为:
policyLoss = cntk.cross_entropy_with_softmax(net.outputs[0], policyVar)
valueLoss = cntk.cross_entropy_with_softmax(net.outputs[1], valueVar)
loss = policyLoss + valueLoss
policyError = cntk.element_not(cntk.classification_error(net.outputs[0], policyVar))
valueError = cntk.element_not(cntk.classification_error(net.outputs[1], valueVar))
#error = (valueError + policyError) / 2
error = valueError # Right now I make due with only viewing valueError for the training data
虽然这很适合训练,但是能够单独查看错误,以便将它们与我使用网络输出手动计算的验证集错误进行比较,将是非常不错的。
我目前正在使用其内置的培训师来像这样训练批次:
progressPrinter = cntk.logging.ProgressPrinter(tag='Training', num_epochs=maxEpochs)
trainer = cntk.Trainer(net, (loss, error), learner, progressPrinter)
for epoch in range(maxEpochs):
miniBatches = 0
while miniBatches < gen.stepsPerEpoch:
X, Y, W = next(g)
miniBatches += 1 # TODO: NEED to make sure this doesn't go over minibatchSize so we're not inputting more than we're saying we are
trainer.train_minibatch({net.arguments[0] : X, policyVar : Y, valueVar : W})
trainer.summarize_training_progress()
是否有办法同时获取policyVar的度量和valueVar的度量以分别显示?我现在还手动计算验证准确性,因为我想同时查看valueVar和policyVar。是否可以用CNTK做到这一点?
当前输出:
Finished Epoch[1 of 100]: [Training] loss = 3.010285 * 9984, metric = 59.91% * 9984 29.532s (338.1 samples/s);
所需的输出(或类似的内容):
Finished Epoch[1 of 100]: [Training] loss = 3.010285 * 9984, (policy)metric = 59.91% * 9984 29.532s (338.1 samples/s);
Finished Epoch[1 of 100]: [Training] loss = 3.010285 * 9984, (value )metric = 63.91% * 9984 29.532s (338.1 samples/s);