[英]Set the weights of a neural networks?
I am coding right now an DRL algorithm that uses the principle of Double DQN with a model and a target which gets updated over time.我现在正在编写一个 DRL 算法,该算法使用双 DQN 原理和一个 model 和一个随时间更新的目标。
So in my code i go this line:所以在我的代码中我 go 这一行:
self.q_next.set_weights(self.q_eval.get_weights())
Which results in the following error message:这会导致以下错误消息:
ValueError: You called set_weights(weights)
on layer "d3qn_1" with a weight list of length 10, but the layer was expecting 0 weights. ValueError:您在“d3qn_1”层上调用set_weights(weights)
,权重列表长度为 10,但该层期望权重为 0。 Provided weights: [array([[[[ 0.04574016, 0.03492326, -0.04824715, ...提供的权重:[array([[[[ 0.04574016, 0.03492326, -0.04824715, ...
Why can i not set the weights of one network to the other?为什么我不能将一个网络的权重设置为另一个?
I fixed this by building the q_next model first, but you need to know the dimension of your inputs ahead.我通过首先构建 q_next model 解决了这个问题,但是您需要提前知道输入的维度。
For example:例如:
self.target_model.build((None, 80, 80, 1))
self.target_model.set_weights(self.model.get_weights())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.