Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于在第一轮回调时的报错信息 #40

Open
ghost opened this issue Jul 27, 2020 · 4 comments
Open

关于在第一轮回调时的报错信息 #40

ghost opened this issue Jul 27, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jul 27, 2020

在训练了1个epoch后,开始回调时出现了下面这个报错信息:

Traceback (most recent call last):
File "run.py", line 166, in
tf.app.run()
File "e:\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "run.py", line 157, in main
train_model(FLAGS)
File "D:\garbage_classification\garbage_classify-master\train.py", line 134, in train_model
shuffle=False
File "e:\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "e:\Anaconda3\lib\site-packages\keras\engine\training.py", line 1732, in fit_generator
initial_epoch=initial_epoch)
File "e:\Anaconda3\lib\site-packages\keras\engine\training_generator.py", line 242, in fit_generator
workers=0)
File "e:\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "e:\Anaconda3\lib\site-packages\keras\engine\training.py", line 1791, in evaluate_generator
verbose=verbose)
File "e:\Anaconda3\lib\site-packages\keras\engine\training_generator.py", line 341, in evaluate_generator
callbacks._call_begin_hook('test')
File "e:\Anaconda3\lib\site-packages\keras\callbacks\callbacks.py", line 105, in _call_begin_hook
self.on_test_begin()
File "e:\Anaconda3\lib\site-packages\keras\callbacks\callbacks.py", line 239, in on_test_begin
callback.on_test_begin(logs)
AttributeError: 'WarmUpCosineDecayScheduler' object has no attribute 'on_test_begin'

我的运行环境和作者的是一样的,用笔记本跑的代码,所以把调用GPU的代码注释了
报错信息上说WarmUpCosineDecayScheduler这个类缺少on_test_begin,我看了一下作者重写的这个回调类里确实没有,但是我单独运行这个类检查是没问题的,不知道该怎么改,求解答,非常感谢!

@wusaifei
Copy link
Owner

wusaifei commented Aug 2, 2020

你好,这个的原因应该是你的callback的版本没有这个on_test_begin这个,说明keras安装包的版本不对应呢。

@wusaifei
Copy link
Owner

wusaifei commented Aug 2, 2020

我这边测试的时候是木有这个报错的

@wusaifei
Copy link
Owner

wusaifei commented Aug 2, 2020

reduce_lr = ks.callbacks.ReduceLROnPlateau(monitor='val_acc', factor=0.5, verbose=1, patience=1, min_lr=1e-7)你换成这个也可以的,这个效果和WarmUpCosineDecayScheduler差不多的。把reduce_lr 加到callback里面。

@ghost
Copy link
Author

ghost commented Aug 2, 2020

感谢大佬的耐心解答,问题已解决!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant