fluid.layers.assign op 训练时报错
Created by: maosengshulei
单机训练时:
vars = list(self.learn_program.list_vars())
target_vars = list(
filter(lambda x: 'GRAD' not in x.name and 'target' in x.name, vars))
policy_vars_name = [
x.name.replace('target', 'policy') for x in target_vars
]
policy_vars = list(filter(lambda x: x.name in policy_vars_name, vars))
policy_vars.sort(key=lambda x: x.name)
target_vars.sort(key=lambda x: x.name)
with fluid.program_guard(self._sync_program):
sync_ops = []
decay = 1.0 - TAU
for i, var in enumerate(policy_vars):
#sync_op = fluid.layers.assign(decay * target_vars[i] + (1 - decay) * policy_vars[i], target_vars[i])
sync_op = fluid.layers.assign(policy_vars[i], target_vars[i])
sync_ops.append(sync_op)`
训练正常。 当我想把这种hard target updates 的方式换成soft target updates 即:
with fluid.program_guard(self._sync_program):
sync_ops = []
decay = 1.0 - TAU
for i, var in enumerate(policy_vars):
sync_op = fluid.layers.assign(decay * target_vars[i] + (1 - decay) * policy_vars[i], target_vars[i])
#sync_op = fluid.layers.assign(policy_vars[i], target_vars[i])
sync_ops.append(sync_op)`
训练时会报错: Error: The Input Variable(X) of assign Op used to determine kernel data type is empty or not LoDTensor or SelectedRows. [Hint: Expected data_type != dafault_data_type, but received data_type:-1 == dafault_data_type:-1.] at (/home/teamcity/work/ef54dc8a5b211854/paddle/fluid/framework/operator.cc:1303) [operator < assign > error]
请教一下错误的原因,和实现soft target update的方法