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

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

Open
wuxun-zhang opened this issue Mar 19, 2019 · 7 comments
Open

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

wuxun-zhang opened this issue Mar 19, 2019 · 7 comments
Labels
Example Python v1.x Targeting v1.x branch

Comments

@wuxun-zhang
Copy link
Contributor

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?

@mxnet-label-bot
Copy link
Contributor

Hey, this is the MXNet Label Bot.
Thank you for submitting the issue! I will try and suggest some labels so that the appropriate MXNet community members can help resolve it.
Here are my recommended labels: Bug

@chinakook
Copy link
Contributor

I think you can have a try with (gluon-cv)[https://github.com/dmlc/gluon-cv]. It has a better version of SSD and is more accuracy.

@zachgk
Copy link
Contributor

zachgk commented Mar 19, 2019

@mxnet-label-bot add [Python, Example]

@wuxun-zhang
Copy link
Contributor Author

I think this issue is caused by this PR#13471. This PR added the new method reset_local for EvalMetric class in metric.py . When training SSD model, MultiBoxMetric class inherited from EvalMetric is defined to evaluate training speed and accuracy in Line22. In MultiBoxMetric class, reset() method is being override for adapting Multi-box training and don't override reset_local() method.

wuxun-zhang added a commit to wuxun-zhang/incubator-mxnet that referenced this issue Mar 24, 2019
@knowledgecomputer2018
Copy link

hi i have this error. why ?
solution:
first i have a array or numpy.float64 K[i] then other line i have a var K=PK . what is meaning i have two var with two type .
god willing

@SRIJONS
Copy link

SRIJONS commented Jun 22, 2020

Has this issue been solved? This mainly "float-str" conversion problem. I'm facing similar problem while trying to access index[0] for a list in Python.

@atulk79
Copy link

atulk79 commented Jul 31, 2020

As Wuxun Zhang commented, define a function reset_local() in the class MultiBoxMetric to override the new method

@szha szha added the v1.x Targeting v1.x branch label Jul 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Example Python v1.x Targeting v1.x branch
Projects
None yet
Development

No branches or pull requests

9 participants