You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2017/12/09 00:17:51 UTC

[GitHub] taliesinb opened a new issue #9007: float16 argmax breaks on negative inputs

taliesinb opened a new issue #9007: float16 argmax breaks on negative inputs
URL: https://github.com/apache/incubator-mxnet/issues/9007
 
 
   ## Description
   
   float16 implementation of argmax seems to treat negative numbers as if they were zero. 
   
   ## Environment info (Required)
   
   ```
   ----------Python Info----------
   Version      : 3.6.1
   Compiler     : GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)
   Build        : ('default', 'May 11 2017 13:04:09')
   Arch         : ('64bit', '')
   ------------Pip Info-----------
   Version      : 9.0.1
   Directory    : /Users/taliesinb/.anaconda3/lib/python3.6/site-packages/pip
   ----------MXNet Info-----------
   Version      : 0.12.1
   Directory    : /Users/taliesinb/.anaconda3/lib/python3.6/site-packages/mxnet-0.12.1-py3.6.egg/mxnet
   Hashtag not found. Not installed from pre-built package.
   ----------System Info----------
   Platform     : Darwin-17.3.0-x86_64-i386-64bit
   system       : Darwin
   node         : T-Book.local
   release      : 17.3.0
   version      : Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64
   ----------Hardware Info----------
   machine      : x86_64
   processor    : i386
   b'machdep.cpu.brand_string: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz'
   b'machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C'
   b'machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID SMAP RDSEED ADX IPT SGX FPU_CSDS MPX CLFSOPT'
   b'machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT PREFETCHW RDTSCP TSCI'
   ----------Network Test----------
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.2516 sec, LOAD: 1.4235 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.3097 sec, LOAD: 0.5009 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.4425 sec, LOAD: 1.4291 sec.
   Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.2759 sec, LOAD: 1.3082 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.2479 sec, LOAD: 1.0078 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.2734 sec, LOAD: 0.7072 sec.
   
   ```
   
   Package used (Python/R/Scala/Julia):
   I'm using Python.
   
   ## Minimum reproducible example
   
   This code will calculate the argmax on two three-vectors, returning two integers. The first integer is  correct, the second, which corresponds to the negative inputs, is incorrect. Seems to happen on both CPU and GPU.
   
   ```
   import mxnet as mx
   import numpy as np
   data = mx.symbol.Variable('data')
   argmax = mx.symbol.argmax(data, axis=-1)
   exec = argmax.simple_bind(ctx=mx.cpu(), data=(2, 3), type_dict={'data':np.float16})
   exec.forward(is_train=True, data=np.asarray([[1,2,3],[-4,-3,-2]], dtype=np.float16))
   exec.outputs
   ```
   
   This messes up accuracy metrics, for example, when doing half-precision training. You can work around it by adding a large constant offset before taking the argmax, but its obviously a horrible hack that isn't always going to work.

----------------------------------------------------------------
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