Neutron3529 opened a new issue #18506: URL: https://github.com/apache/incubator-mxnet/issues/18506
## Description In the current version of `KLDivLoss`, the return value is not the same value calculated by SoftmaxCrossEntropyLoss, which is not documented. It may due to the incorrect settings which using mean rather than sum dealing with the return value. A PR(PR#18423) is submitted to overcome such misbehave. In addition, this PR also fix `SDMLLoss` which uses `KLDivLoss`'s result. ### Error Message (no error message) ## To Reproduce >>> o=mx.nd.array([[1,2,3]]) >>> l=mx.nd.array([1]) >>> lo=l.one_hot(o.shape[1]) >>> mx.gluon.loss.SoftmaxCrossEntropyLoss()(o,l)#correct answer. [1.4076059] <NDArray 1 @cpu(0)> >>> mx.gluon.loss.KLDivLoss(from_logits=False)(o,lo)#not equals to the previous result. [0.46920195] <NDArray 1 @cpu(0)> >>> mx.gluon.loss.KLDivLoss(from_logits=False)(o,lo)*o.shape[1]#this is what the document say. [1.4076059] <NDArray 1 @cpu(0)> ## Environment We recommend using our script for collecting the diagnositc information. Run the following command and paste the outputs below: ``` curl --retry 10 -s https://raw.githubusercontent.com/dmlc/gluon-nlp/master/tools/diagnose.py | python ----------Python Info---------- Version : 3.8.3 Compiler : GCC 10.1.0 Build : ('default', 'May 17 2020 18:15:42') Arch : ('64bit', 'ELF') ------------Pip Info----------- Version : 20.0.2 Directory : /usr/lib/python3.8/site-packages/pip ----------MXNet Info----------- Version : 1.6.0 Directory : /home/neutron/.local/lib/python3.8/site-packages/mxnet Num GPUs : 1 Commit Hash : 6eec9da55c5096079355d1f1a5fa58dcf35d6752 ----------System Info---------- Platform : Linux-5.4.43-1-MANJARO-x86_64-with-glibc2.2.5 system : Linux node : Neutron release : 5.4.43-1-MANJARO version : #1 SMP PREEMPT Wed May 27 20:25:12 UTC 2020 ----------Hardware Info---------- machine : x86_64 processor : 架构: x86_64 CPU 运行模式: 32-bit, 64-bit 字节序: Little Endian Address sizes: 39 bits physical, 48 bits virtual CPU: 12 在线 CPU 列表: 0-11 每个核的线程数: 2 每个座的核数: 6 座: 1 NUMA 节点: 1 厂商 ID: GenuineIntel CPU 系列: 6 型号: 158 型号名称: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz 步进: 10 CPU MHz: 2803.323 CPU 最大 MHz: 4100.0000 CPU 最小 MHz: 800.0000 BogoMIPS: 4401.32 虚拟化: VT-x L1d 缓存: 192 KiB L1i 缓存: 192 KiB L2 缓存: 1.5 MiB L3 缓存: 9 MiB NUMA 节点0 CPU: 0-11 Vulnerability Itlb multihit: KVM: Mitigation: Split huge pages Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling Vulnerability Tsx async abort: Not affected 标记: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm p be syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aper fmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mp x rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_w indow hwp_epp md_clear flush_l1d ----------Network Test---------- Setting timeout: 10 Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0006 sec, LOAD: 1.1995 sec. Timing for GluonNLP GitHub: https://github.com/dmlc/gluon-nlp, DNS: 0.0003 sec, LOAD: 2.3723 sec. Timing for GluonNLP: http://gluon-nlp.mxnet.io, DNS: 0.4260 sec, LOAD: 1.6315 sec. Timing for D2L: http://d2l.ai, DNS: 1.2683 sec, LOAD: 0.6324 sec. Timing for D2L (zh-cn): http://zh.d2l.ai, DNS: 0.2637 sec, LOAD: 0.6168 sec. Timing for FashionMNIST: https://repo.mxnet.io/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.4871 sec, LOAD: 1.0879 sec. Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0196 sec, LOAD: 1.7082 sec. Error open Conda: https://repo.continuum.io/pkgs/free/, HTTP Error 403: Forbidden, DNS finished in 0.31757044792175293 sec. ``` ---------------------------------------------------------------- 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: [email protected]
