Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

TypeError: 'float' object is not subscriptable` #14468

@wuxun-zhang

Description

@wuxun-zhang

Description

When I ran ssd training using this script, I got an error TypeError: 'float' object is not subscriptable. I tried this example on both GPU and CPU, but there always have the same problem.

Environment info (Required)

----------Python Info----------
Version      : 3.6.3
Compiler     : GCC 7.2.0
Build        : ('default', 'Oct 13 2017 12:02:49')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 19.0.3
Directory    : /home/wuxunzha/anaconda3/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Version      : 1.5.0
Directory    : /home/wuxunzha/github/incubator-mxnet/python/mxnet
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform     : Linux-3.10.0-693.el7.x86_64-x86_64-with-centos-7.4.1708-Core
system       : Linux
node         : mlt-skx090
release      : 3.10.0-693.el7.x86_64
version      : #1 SMP Tue Aug 22 21:09:27 UTC 2017
----------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):                80
On-line CPU(s) list:   0-79
Thread(s) per core:    2
Core(s) per socket:    20
Socket(s):             2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 85
Model name:            Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
Stepping:              4
CPU MHz:               2570.625
CPU max MHz:           3700.0000
CPU min MHz:           1000.0000
BogoMIPS:              4800.00
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              1024K
L3 cache:              28160K
NUMA node0 CPU(s):     0-19,40-59
NUMA node1 CPU(s):     20-39,60-79
Flags:                 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 pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0032 sec, LOAD: 2.1229 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 1.4518 sec, LOAD: 4.9281 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0081 sec, LOAD: 4.5625 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0157 sec, LOAD: 2.1068 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0033 sec, LOAD: 7.5540 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0090 sec, LOAD: 4.2230 sec.

Package used (Python/R/Scala/Julia):

I'm using Python.

Build info (Required if built from source)

gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

MXNet commit hash:
ed77d6d

Build config:
make USE_OPENCV=1 USE_MKLDNN=1 USE_BLAS=mkl -j

Error Message:

Traceback (most recent call last):
File "train.py", line 153, in
voc07_metric=args.use_voc07_metric)
File "/home/wuxunzha/github/incubator-mxnet/example/ssd/train/train_net.py", line 275, in train_net
monitor=monitor)
File "/home/wuxunzha/github/incubator-mxnet/python/mxnet/module/base_module.py", line 533, in fit
self.update_metric(eval_metric, data_batch.label)
File "/home/wuxunzha/github/incubator-mxnet/python/mxnet/module/module.py", line 773, in update_metric
self.exec_group.update_metric(eval_metric, labels, pre_sliced)
File "/home/wuxunzha/github/incubator-mxnet/python/mxnet/module/executor_group.py", line 639, in update_met ric
eval_metric.update_dict(labels
, preds)
File "/home/wuxunzha/github/incubator-mxnet/python/mxnet/metric.py", line 133, in update_dict
self.update(label, pred)
File "/home/wuxunzha/github/incubator-mxnet/example/ssd/train/metric.py", line 57, in update
self.sum_metric[0] += (-np.log(prob + self.eps)).sum()
TypeError: 'float' object is not subscriptable

Minimum reproducible example

Just this script.

Steps to reproduce

1: cd example/ssd
2: python train.py --pretrained /home/wuxunzha/distributed_training _lastest/ssd/pretrained/ssd_vgg16_reduced_300 --epoch 0 --gpus 0

Also you can follow this README to prepare dataset, and rerun this script.

What have you tried to solve it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions