Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7A284200D4F for ; Wed, 22 Nov 2017 02:44:19 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 78A2F160BFC; Wed, 22 Nov 2017 01:44:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C6235160C0E for ; Wed, 22 Nov 2017 02:44:18 +0100 (CET) Received: (qmail 2026 invoked by uid 500); 22 Nov 2017 01:44:18 -0000 Mailing-List: contact commits-help@mxnet.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mxnet.incubator.apache.org Delivered-To: mailing list commits@mxnet.incubator.apache.org Received: (qmail 2017 invoked by uid 99); 22 Nov 2017 01:44:18 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Nov 2017 01:44:18 +0000 From: GitBox To: commits@mxnet.apache.org Subject: [GitHub] javelinjs closed pull request #8297: [scala] Make accuracy idependant of output size (fix #8226) Message-ID: <151131505747.13700.4632256545213445154.gitbox@gitbox.apache.org> archived-at: Wed, 22 Nov 2017 01:44:19 -0000 javelinjs closed pull request #8297: [scala] Make accuracy idependant of output size (fix #8226) URL: https://github.com/apache/incubator-mxnet/pull/8297 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala b/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala index 6b993d7665..98a09d2250 100644 --- a/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala +++ b/scala-package/core/src/main/scala/ml/dmlc/mxnet/EvalMetric.scala @@ -26,7 +26,7 @@ import scala.collection.mutable.ArrayBuffer abstract class EvalMetric(protected val name: String) { protected var numInst: Int = 0 - protected var sumMetric: Float = 0.0f + protected var sumMetric: Double = 0.0d /** * Update the internal evaluation. @@ -41,7 +41,7 @@ abstract class EvalMetric(protected val name: String) { */ def reset(): Unit = { this.numInst = 0 - this.sumMetric = 0.0f + this.sumMetric = 0.0d } /** @@ -50,7 +50,7 @@ abstract class EvalMetric(protected val name: String) { * value, Value of the evaluation */ def get: (Array[String], Array[Float]) = { - (Array(this.name), Array(this.sumMetric / this.numInst)) + (Array(this.name), Array((this.sumMetric / this.numInst).toFloat)) } } @@ -111,11 +111,10 @@ class Accuracy extends EvalMetric("accuracy") { require(label.shape == predLabel.shape, s"label ${label.shape} and prediction ${predLabel.shape}" + s"should have the same length.") - for ((labelElem, predElem) <- label.toArray zip predLabel.toArray) { - if (labelElem == predElem) { - this.sumMetric += 1 - } - } + + this.sumMetric += label.toArray.zip(predLabel.toArray) + .filter{ case (labelElem: Float, predElem: Float) => labelElem == predElem } + .size this.numInst += predLabel.shape(0) predLabel.dispose() } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services