bert run_classifier key error = '0'

Created on 11 Feb 2020  路  1Comment  路  Source: google-research/bert

File "run_classifier.py", line 981, in
tf.app.run()
File "C:UsersParveenishanbertenvlibsite-packagestensorflow_corepythonplatformapp.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:UsersParveenishanbertenvlibsite-packagesabslapp.py", line 299, in run
_run_main(main, args)
File "C:UsersParveenishanbertenvlibsite-packagesabslapp.py", line 250, in _run_main
sys.exit(main(argv))
File "run_classifier.py", line 942, in main
predict_file)
File "run_classifier.py", line 490, in file_based_convert_examples_to_features
max_seq_length, tokenizer)
File "run_classifier.py", line 459, in convert_single_example
label_id = label_map[example.label]
KeyError: '0'

I have changed the labels in the colaProcessor class and my training is successful, I am getting this error during testing. Please help

Most helpful comment

I had the same problem. Training was successful but testing threw KeyError: '0'. I solved the problem by changing labels to a list of stringified integers. ["e","k_1980", "k_1990", "k_2000", "k_2010"]produced the KeyError but ["0", "1", "2", "3", "4"] worked fine.

>All comments

I had the same problem. Training was successful but testing threw KeyError: '0'. I solved the problem by changing labels to a list of stringified integers. ["e","k_1980", "k_1990", "k_2000", "k_2010"]produced the KeyError but ["0", "1", "2", "3", "4"] worked fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okgrammer picture okgrammer  路  4Comments

yyht picture yyht  路  3Comments

wangwei7175878 picture wangwei7175878  路  4Comments

santhoshkolloju picture santhoshkolloju  路  3Comments

allenzhang010 picture allenzhang010  路  3Comments