Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Keras K.功能';s第三个参数,更新时需要有新旧权重对以外的操作?_Keras - Fatal编程技术网

Keras K.功能';s第三个参数,更新时需要有新旧权重对以外的操作?

Keras K.功能';s第三个参数,更新时需要有新旧权重对以外的操作?,keras,Keras,我一直在构建DDPG代理,这是增强学习的算法。不管怎样,我找到了一些可以参考的资料。那些似乎起作用了。但是,我对在keras中使用K.function()感到困惑。 在下面,函数“get_soft_target_model_updates”返回(旧权重、新权重),这与keras官方文档所写的“更新:更新操作列表”不同。所以,我认为它需要返回K.update(旧张量,新张量) def get_soft_target_model_更新(目标、源、tau): 目标权重=目标可训练权重+总和([l.目标

我一直在构建DDPG代理,这是增强学习的算法。不管怎样,我找到了一些可以参考的资料。那些似乎起作用了。但是,我对在keras中使用K.function()感到困惑。 在下面,函数“get_soft_target_model_updates”返回(旧权重、新权重),这与keras官方文档所写的“更新:更新操作列表”不同。所以,我认为它需要返回K.update(旧张量,新张量)

def get_soft_target_model_更新(目标、源、tau):
目标权重=目标可训练权重+总和([l.目标层中l的非可训练权重],])
source_权重=source.trainable_权重+总和([l.source.layers中l的非可训练_权重],])
断言len(目标权重)=len(源权重)
更新=[]
对于zip中的tw、sw(目标权重、源权重):
更新。追加((tw,tau*sw+(1.-tau)*tw))
返回更新
如果self.tau_for_actor<1:
更新+=获取软目标模型更新(self.target\u actor、self.actor、self.tau\u for\u actor)
更新+=self.actor.updates
self.actor\u train\u fn=K.函数(状态输入+[K.学习阶段()],[self.actor(状态输入)],更新=更新)
def get_soft_target_model_updates(target, source, tau):
    target_weights = target.trainable_weights + sum([l.non_trainable_weights for l in target.layers], [])
    source_weights = source.trainable_weights + sum([l.non_trainable_weights for l in source.layers], [])
    assert len(target_weights) == len(source_weights)

    updates = []
    for tw, sw in zip(target_weights, source_weights):
        updates.append((tw, tau * sw + (1. - tau) * tw))
    return updates


    if self.tau_for_actor < 1:
        updates += get_soft_target_model_updates(self.target_actor, self.actor, self.tau_for_actor)

    updates += self.actor.updates

    self.actor_train_fn = K.function(state_inputs + [K.learning_phase()], [self.actor(state_inputs)], updates=updates)