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 2019/10/12 10:05:10 UTC

[GitHub] [incubator-mxnet] vafl opened a new issue #16460: numpy -> mxnet -> numpy gives arrays with strange behavior

vafl opened a new issue #16460: numpy -> mxnet -> numpy gives arrays with strange behavior 
URL: https://github.com/apache/incubator-mxnet/issues/16460
 
 
   ## Description
   
   Converting numpy arrays to mxnet and back again can give numpy arrays that behave very strangely.
   
   Minimal example:
   
   ```python
   import mxnet as mx
   import numpy as np
   
   n = 1_000_000
   
   # Create an array with two columns with values 100 and -100
   # x.shape = (n, 2)
   x = np.array([100.0, -100.0])[None, :].repeat(repeats=n, axis=0)
   
   print(x.std(axis=0))  # gives -> [0., 0.]
   
   # convert this numpy array to mxnet and back again gives a numpy array that
   # behaves very strangely
   u = mx.nd.array(x).asnumpy()
   
   print(u.std(axis=0))  # gives a different result! -> [1.3201232, 1.3201232]
   
   # looking at each column individually doesn't show this
   print(u[:, 0].std())  # gives -> 0.
   
   # serializing the array to a list and back gives an array that behaves normal again
   t = np.array(u.tolist())
   print(t.std(axis=0))  # gives -> [0., 0.]
   ```
   
   It doesn't happen with smaller values of `n` such as `100_000`.
   
   ## Environment info (Required)
   
   ```
   ----------Python Info----------
   Version      : 3.7.4
   Compiler     : Clang 10.0.1 (clang-1001.0.46.4)
   Build        : ('default', 'Sep  7 2019 18:27:02')
   Arch         : ('64bit', '')
   ------------Pip Info-----------
   Version      : 19.1.1
   Directory    : /usr/local/lib/python3.7/site-packages/pip
   ----------MXNet Info-----------
   Version      : 1.5.1
   Directory    : /usr/local/lib/python3.7/site-packages/mxnet
   Commit Hash   : c9818480680f84daa6e281a974ab263691302ba8
   Library      : ['/usr/local/lib/python3.7/site-packages/mxnet/libmxnet.so']
   Build features:
   ✖ CUDA
   ✖ CUDNN
   ✖ NCCL
   ✖ CUDA_RTC
   ✖ TENSORRT
   ✔ CPU_SSE
   ✔ CPU_SSE2
   ✔ CPU_SSE3
   ✔ CPU_SSE4_1
   ✔ CPU_SSE4_2
   ✖ CPU_SSE4A
   ✔ CPU_AVX
   ✖ CPU_AVX2
   ✖ OPENMP
   ✖ SSE
   ✖ F16C
   ✖ JEMALLOC
   ✖ BLAS_OPEN
   ✖ BLAS_ATLAS
   ✖ BLAS_MKL
   ✖ BLAS_APPLE
   ✔ LAPACK
   ✖ MKLDNN
   ✔ OPENCV
   ✖ CAFFE
   ✖ PROFILER
   ✔ DIST_KVSTORE
   ✖ CXX14
   ✖ INT64_TENSOR_SIZE
   ✔ SIGNAL_HANDLER
   ✖ DEBUG
   ----------System Info----------
   Platform     : Darwin-18.7.0-x86_64-i386-64bit
   system       : Darwin
   node         : 88e9fe6a91e5.ant.amazon.com
   release      : 18.7.0
   version      : Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64
   ----------Hardware Info----------
   machine      : x86_64
   processor    : i386
   b'machdep.cpu.brand_string: Intel(R) Core(TM) i7-7660U CPU @ 2.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 SMX 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: RDWRFSGS TSC_THREAD_OFFSET SGX BMI1 HLE AVX2 SMEP BMI2 ERMS INVPCID RTM FPU_CSDS MPX RDSEED ADX SMAP CLFSOPT IPT MDCLEAR TSXFA IBRS STIBP L1DF SSBD'
   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.0579 sec, LOAD: 0.7154 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0700 sec, LOAD: 0.8928 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0789 sec, LOAD: 0.8982 sec.
   Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0706 sec, LOAD: 0.4380 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0532 sec, LOAD: 0.6719 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0372 sec, LOAD: 0.4545 sec.
   ----------Environment----------
   KMP_DUPLICATE_LIB_OK="True"
   ```
   
   Package used (Python/R/Scala/Julia):
   (I'm using ...) Python
   
   ## Minimum reproducible example
   see above
   
   ## Steps to reproduce
   run the script
   
   ## What have you tried to solve it?
   I could reproduce this also with mxnet 1.4.1 and with the `conda_amazonei_mxnet_p36` kernel on a linux sagmaker instance.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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