首页 Paddle框架 帖子详情
batch_norm添加is_test参数后报错,(原先正常运行)
收藏
快速回复
Paddle框架 问答深度学习模型训练炼丹技巧 979 7
batch_norm添加is_test参数后报错,(原先正常运行)
收藏
快速回复
Paddle框架 问答深度学习模型训练炼丹技巧 979 7

System information
-PaddlePaddle version 1.6.1
-CPU: Inter(R) Xeon(R) E-2176M
-GPU: Quadro P3200, CUDA Version: 10.1,cuDNN Version: 7.6.
-OS Platform (eg.Mac OS 10.14) win10
-Python version:3.7

all happens afer I add is_test=True to fluid.layers.batch_norm.........
logs likes this:

EnforceNotMet Traceback (most recent call last)
in ()
60 train_cost, train_acc = exe.run(program=fluid.default_main_program(),#运行主程序
61 feed=feeder.feed(data), #给模型喂入数据
---> 62 fetch_list=[avg_cost, acc]) #fetch 误差、准确率
63
64 all_train_iter=all_train_iter+BATCH_SIZE

D:\Anaconda3\lib\site-packages\paddle\fluid\executor.py in run(self, program, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
773 warnings.warn(
774 "The following exception is not an EOF exception.")
--> 775 six.reraise(*sys.exc_info())
776
777 def _run_impl(self, program, feed, fetch_list, feed_var_name,

D:\Anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
691 if value.traceback is not tb:
692 raise value.with_traceback(tb)
--> 693 raise value
694 finally:
695 value = None

D:\Anaconda3\lib\site-packages\paddle\fluid\executor.py in run(self, program, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
768 scope=scope,
769 return_numpy=return_numpy,
--> 770 use_program_cache=use_program_cache)
771 except Exception as e:
772 if not isinstance(e, core.EOFException):

D:\Anaconda3\lib\site-packages\paddle\fluid\executor.py in _run_impl(self, program, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
815 scope=scope,
816 return_numpy=return_numpy,
--> 817 use_program_cache=use_program_cache)
818
819 program._compile(scope, self.place)

D:\Anaconda3\lib\site-packages\paddle\fluid\executor.py in _run_program(self, program, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
892 if not use_program_cache:
893 self._default_executor.run(program.desc, scope, 0, True, True,
--> 894 fetch_var_name)
895 else:
896 self._default_executor.run_cached_prepared_ctx(ctx, scope, False,

EnforceNotMet:


C++ Call Stacks (More useful to developers):

Windows not support stack backtrace yet.


Python Call Stacks (More useful to users):

File "D:\Anaconda3\lib\site-packages\paddle\fluid\framework.py", line 2459, in append_op
attrs=kwargs.get("attrs", None))
File "D:\Anaconda3\lib\site-packages\paddle\fluid\layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\paddle\fluid\layers\nn.py", line 4331, in batch_norm
"use_global_stats": use_global_stats
File "", line 116, in ModelBlendding
hidden3_ = fluid.layers.batch_norm(input=hidden6,is_test=True,param_attr = param_attrs,bias_attr = param_attrs)
File "", line 11, in
predict = ModelBlendding(C,S,L)
File "D:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "D:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2903, in run_ast_nodes
if self.run_code(code, result):
File "D:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2785, in _run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "D:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2662, in run_cell
raw_cell, store_history, silent, shell_futures)
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "D:\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "D:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "D:\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 536, in
self.io_loop.add_callback(lambda : self._handle_events(self.socket, 0))
File "D:\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "D:\Anaconda3\lib\site-packages\tornado\ioloop.py", line 605, in _run_callback
ret = callback()
File "D:\Anaconda3\lib\site-packages\tornado\ioloop.py", line 832, in start
self._run_callback(self._callbacks.popleft())
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel\kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "D:\Anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "D:\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)


Error Message Summary:

PaddleCheckError: holder_ should not be null
Tensor holds no memory. Call Tensor::mutable_data first. at [D:\1.6.1\paddle\paddle\fluid\framework\tensor.cc:23]
[operator < batch_norm_grad > error]

0
收藏
回复
全部评论(7)
时间顺序
AIStudio788475
#2 回复于2019-11

请问原先运行正常是指在早先的版本设置is_test=True运行正常,还是指在1.6.1版本设置不设置is_test=True运行正常?

0
回复
AIStudio792865
#3 回复于2019-11

请问原先运行正常是指在早先的版本设置is_test=True运行正常,还是指在1.6.1版本设置不设置is_test=True运行正常?

尴尬,我标题搞错了,是添加之后不能运行

0
回复
AIStudio788475
#4 回复于2019-11

请问原先运行正常是指在早先的版本设置is_test=True运行正常,还是指在1.6.1版本设置不设置is_test=True运行正常?

尴尬,我标题搞错了,是添加之后不能运行

请问是训练过程还是预测过程?

0
回复
AIStudio788475
#5 回复于2019-11

true只能用于inference模式

0
回复
AIStudio792865
#6 回复于2019-11
0
回复
AIStudio788475
#7 回复于2019-11

我不太明白,参数设置是在模型的时候,推断时无需重新定义模型,那个这个参数的存在意义在何?难道有什么操作可以做推断时重新定义模型?那样的话,模型训练的意思又在哪呢 发自我的小米手机 在 Xiaoyang LI notifications@github.com,2019年11月27日 下午12:26写道: true只能用于inference模式 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#21385?email_source=notifications&email_token=AI2M6S77EPLNX3VXQXB5DNLQVXZF5A5CNFSM4JSASTN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFIHXZQ#issuecomment-558922726>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AI2M6SZKP6WKYMGPGWNQW2LQVXZF5ANCNFSM4JSASTNQ.

需要分别构建训练和预测的program,预测program的model可以把这个参数设置成True

0
回复
AIStudio792865
#8 回复于2019-11

在clone default_main_program加上for_test来实现同样的功能即可

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户