def test(self, inputs, targets):
if not self.model:
raise RuntimeError, "Model not trained!"
metrics = self.model.evaluate(inputs, targets)
print >>sys.stderr, "Test accuracy: %.4f" % (metrics[1]) # The first metric is loss.
predictions = numpy.argmax(self.model.predict(inputs), axis=1)
rev_label_map = {ind: label for label, ind in self.label_map.items()}
predicted_labels = [rev_label_map[pred] for pred in predictions]
return predicted_labels
评论列表
文章目录