简体   繁体   中英

During activating Tensorflow program, Error 'NoneType' object has no attribute 'group'. How can I solve this?

When I was using Tensorflow to follow the tutorial of Simple Audio Recognition on TensorFlow page, I got a problem in downloading audio data for train.

I have entered the following command:

C:\Users\user\Document\Tensorflow\tensorflow\examples\speech_commands\train.py

and got an error message,

 Downloading speech_commands_v0.01.tar.gz 100.0%
INFO:tensorflow:Successfully downloaded speech_commands_v0.01.tar.gz (1488293908 bytes)
Traceback (most recent call last):
  File "C:\Users\user\Document\Tensorflow\tensorflow\examples\speech_commands\train.py", line 427, in <module>
    tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "C:\Users\user\AppData\Local\conda\conda\envs\my_root\lib\site-packages\tensorflow\python\platform\app.py", line 133, in run
    _sys.exit(main(argv))
  File "C:\Users\user\Document\Tensorflow\tensorflow\examples\speech_commands\train.py", line 104, in main
    FLAGS.testing_percentage, model_settings)
  File "C:\Users\user\Document\Tensorflow\tensorflow\examples\speech_commands\input_data.py", line 161, in __init__
    testing_percentage)
  File "C:\Users\user\Document\Tensorflow\tensorflow\examples\speech_commands\input_data.py", line 243, in prepare_data_index
    word = re.search('.*/([^/]+)/.*.wav', wav_path).group(1).lower()
AttributeError: 'NoneType' object has no attribute 'group'

Should I fix the code on file input_data.py? If it is possible, how can I fix it? It will be helpful if anyone gives me some advice on this problem.

The error suggests that your re.search() call returned None , hence the AttributeError you are getting.

I suggest you give a better look to your regexp to check that is what you desire. Another thing that I noted is that you are also calling group(1) . Make sure that is also the group you wish to obtain with that regexp (and not group(0) ). Alternatively, the groups() method will return all the subgroups of your match. Hope this helps.

I think it'a python error instead of a tensorflow error.

There's no match for your regexp in re.search()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM