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/06/10 04:12:59 UTC

[GitHub] [incubator-mxnet] shaoanlu opened a new issue #15192: Confusing Total params in mxnet.visualization.print_summary

shaoanlu opened a new issue #15192: Confusing Total params in mxnet.visualization.print_summary
URL: https://github.com/apache/incubator-mxnet/issues/15192
 
 
   ## Description
   I observed inconsistent number of params in `mxnet.visualization.print_summary` with actual weights when FullyConnected having `flatten=True` set.
   
   ## Environment info (Required)
   I ran the experiment on Google Colab.
   
   ```
   ----------Python Info----------
   Version      : 3.6.7
   Compiler     : GCC 8.2.0
   Build        : ('default', 'Oct 22 2018 11:32:17')
   Arch         : ('64bit', '')
   ------------Pip Info-----------
   Version      : 19.1.1
   Directory    : /usr/local/lib/python3.6/dist-packages/pip
   ----------MXNet Info-----------
   Version      : 1.4.1
   Directory    : /usr/local/lib/python3.6/dist-packages/mxnet
   Hashtag not found. Not installed from pre-built package.
   ----------System Info----------
   Platform     : Linux-4.14.79+-x86_64-with-Ubuntu-18.04-bionic
   system       : Linux
   node         : 0ef71a01d851
   release      : 4.14.79+
   version      : #1 SMP Wed Dec 19 21:19:13 PST 2018
   ----------Hardware Info----------
   machine      : x86_64
   processor    : x86_64
   Architecture:        x86_64
   CPU op-mode(s):      32-bit, 64-bit
   Byte Order:          Little Endian
   CPU(s):              2
   On-line CPU(s) list: 0,1
   Thread(s) per core:  2
   Core(s) per socket:  1
   Socket(s):           1
   NUMA node(s):        1
   Vendor ID:           GenuineIntel
   CPU family:          6
   Model:               63
   Model name:          Intel(R) Xeon(R) CPU @ 2.30GHz
   Stepping:            0
   CPU MHz:             2300.000
   BogoMIPS:            4600.00
   Hypervisor vendor:   KVM
   Virtualization type: full
   L1d cache:           32K
   L1i cache:           32K
   L2 cache:            256K
   L3 cache:            46080K
   NUMA node0 CPU(s):   0,1
   Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt arat arch_capabilities
   ----------Network Test----------
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0151 sec, LOAD: 0.6442 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.0308 sec, LOAD: 0.8126 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0341 sec, LOAD: 0.7928 sec.
   Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0430 sec, LOAD: 0.3666 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0070 sec, LOAD: 0.3116 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0135 sec, LOAD: 0.1245 sec.
   
   ```
   ## Minimum reproducible example
   ```
   inp = mx.symbol.Variable('data')
   op = mx.symbol.FullyConnected(data=inp,num_hidden=1, no_bias=True)
   net = mx.mod.Module(symbol=op, label_names=None, context=mx.gpu())
   net.bind(for_training=False, data_shapes=[('data', (1,3,2,2))])
   net.init_params()
   ```
   When I called `mx.visualization.print_summary(op, shape={'data':(1,3,2,2)})`, it shows the following summary:
   ```
   ________________________________________________________________________________________________________________________
   Layer (type)                                        Output Shape            Param #     Previous Layer                  
   ========================================================================================================================
   data(null)                                          3x2x2                   0                                           
   ________________________________________________________________________________________________________________________
   fullyconnected0(FullyConnected)                     1                       3           data                            
   ========================================================================================================================
   Total params: 3
   ________________________________________________________________________________________________________________________
   ```
   where `Total params` is 3. However, when I inspected the weights through `net.get_params()`, the fully-connected layer has actually 12 params since the input(data) is flattened.
   ```
   ({'fullyconnected0_weight': 
     [[-0.00124826 -0.00404931  0.00783546 -0.00886574  0.00927326 -0.00454687
       -0.00233117 -0.0004467   0.0058345   0.00624337  0.0005779  -0.00040046]]
     <NDArray 1x12 @cpu(0)>}, {})
   ```
   
   ## What have you tried to solve it?
   I tried to modify `visualization.py` so that the `pre_filter` is correctly counted but couldn't find information for parameter `flatten` of `mxnet.symbol.FullyConnected`.
   

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