[英]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. 当我使用Tensorflow遵循TensorFlow页面上的简单音频识别教程时,在下载用于火车的音频数据时遇到了问题。
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? 我应该将代码固定在文件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. 该错误表明您的
re.search()
调用返回了None
,因此得到了AttributeError
。
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)
. 我注意到的另一件事是您也正在调用
group(1)
。 Make sure that is also the group you wish to obtain with that regexp (and not group(0)
). 确保这也是您希望通过该正则表达式获取的组 (而不是
group(0)
)。 Alternatively, the groups()
method will return all the subgroups of your match. 另外,
groups()
方法将返回匹配的所有子组。 Hope this helps. 希望这可以帮助。
I think it'a python error instead of a tensorflow error. 我认为这是python错误而不是tensorflow错误。
There's no match for your regexp in re.search()
re.search()
没有与您的正则表达式匹配的项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.