Paddle:1.6
GPU:V100
AIStudio线上环境
训练信息:
单机单卡
复现信息:
sgd = fluid.optimizer.AdamOptimizer(learning_rate=0.01)
optimizer = fluid.optimizer.LookaheadOptimizer(sgd,alpha=0.5,k=5)
替换房价预测案例optimizer
报错信息:
epoch: 0, batch: 0, loss is: [2.3028119], acc is [0.03125]
---------------------------------------------------------------------------TypeError Traceback (most recent call last) in
5 # optimizer=fluid.optimizer.AdamOptimizer(learning_rate=0.01)
6 pretrained_path = None
----> 7 best_valid_acc = train_model(EPOCH_NUM, optimizer, pretrained_path)
in train_model(EPOCH_NUM, optimizer, pretrained_path, use_gpu)
33 #后向传播,更新参数的过程
34 avg_loss.backward()
---> 35 optimizer.minimize(avg_loss)
36 model.clear_gradients()
37
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/optimizer.py in minimize(self, loss, startup_program)
3716 slow_var, layers.elementwise_sub(one_var, alpha)))
3717 layers.assign(input=tmp_var, output=slow_var)
-> 3718 layers.assign(input=tmp_var, output=fast_var)
3719 with switch.default():
3720 pass
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/control_flow.py inexit(self, exc_type, exc_val, exc_tb)
1588
1589 defexit(self, exc_type, exc_val, exc_tb):
-> 1590 self.block.complete()
1591 return super(ConditionalBlockGuard, self).exit(exc_type, exc_val,
1592 exc_tb)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/control_flow.py in complete(self)
1673 attrs={
1674 'sub_block': inside_block,
-> 1675 'is_scalar_condition': self.is_scalar_condition
1676 })
1677
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py in append_op(self, *args,**kwargs)
2415 kwargs.get("outputs", {}), attrs
2416 if attrs else {},
-> 2417 kwargs.get("stop_gradient", False))
2418 else:
2419 op_desc = self.desc.append_op()
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/tracer.py in trace_op(self, type, inputs, outputs, attrs, stop_gradient)
45 self.trace(type, inputs, outputs, attrs,
46 framework._current_expected_place(), self._train_mode and
---> 47 not stop_gradient)
48
49 def train_mode(self):
TypeError: trace(): incompatible function arguments. The following argument types are supported:
- (self: paddle.fluid.core_avx.Tracer, arg0: str, arg1: Dict[str, handle], arg2: Dict[str, handle], arg3: Dict[str, Variant], arg4: paddle::platform::CUDAPlace, arg5: bool) -> None
- (self: paddle.fluid.core_avx.Tracer, arg0: str, arg1: Dict[str, handle], arg2: Dict[str, handle], arg3: Dict[str, Variant], arg4: paddle::platform::CPUPlace, arg5: bool) -> None
Invoked with: <paddle.fluid.dygraph.tracer.Tracer object at 0x7efb5dc94b90>, 'conditional_block', {'Cond': [name tmp_46, dtype: VarType.INT32 shape: [1] lod: {}
dim: 1
layout: NCHW
dtype: bool
data: [0]
], 'Input': []}, {'Out': [], 'Scope': [name _generated_var_2, shape: [0], not inited]}, {'sub_block': idx: 1
parent_idx: 0
, 'is_scalar_condition': True}, <paddle.fluid.core_avx.CUDAPlace object at 0x7efb5de13430>, True
[10]
8条答案
按热度按时间yvfmudvl1#
问题已复现,处理中
qrjkbowd2#
@LDOUBLEV 可以提供一下复现代码,我们一起看下怎么修复
gpfsuwkq3#
@LDOUBLEV 可以提供一下复现代码,我们一起看下怎么修复
复现代码:
nkkqxpd94#
@LDOUBLEV 我把Lookahead相关的代码注解掉了,问题仍然存在,暂时和LookaheadOptimizer没有关系,麻烦你看下其他原因。
如下是注解掉Lookahead后的代码:
以下为错误:
pxiryf3j5#
@LDOUBLEV 我把Lookahead相关的代码注解掉了,问题仍然存在,暂时和LookaheadOptimizer没有关系,麻烦你看下其他原因。
如下是注解掉Lookahead后的代码:
以下为错误:
用户的环境是1.6,你用的应该是基于develop分支下的,最新develop分支下的动态图,optimizer需要指定要优化的参数,你看报错信息里是parameter_list为空。目前关于lookaheadoptimizer的最新结论是:动态图当前不支持lookaheadoptimizer。
smdncfj36#
@GitLD Hi,lookaheadoptimizer在动态图下暂时不可用,建议换其他optimizer进行优化算法,我们会尽快支持。
uqzxnwby7#
@LDOUBLEV 我把Lookahead相关的代码注解掉了,问题仍然存在,暂时和LookaheadOptimizer没有关系,麻烦你看下其他原因。
如下是注解掉Lookahead后的代码:
以下为错误:
用户的环境是1.6,你用的应该是基于develop分支下的,最新develop分支下的动态图,optimizer需要指定要优化的参数,你看报错信息里是parameter_list为空。目前关于lookaheadoptimizer的最新结论是:动态图当前不支持lookaheadoptimizer。
好的,我试一下用1.6复现用户错误。
6tqwzwtp8#
@GitLD Hi,lookaheadoptimizer在动态图下暂时不可用,建议换其他optimizer进行优化算法,我们会尽快支持。
好的,期待不久后能支持上