我试图拟合一个具有不同输出的深度神经网络模型,一个是向量的策略输出,一个是标量的值输出。我还想实现经验回放。这就是为什么我想在每个时代之后训练模型
我不知道什么是最好的方法,但在网上学习了一些教程后,我想出了以下代码来训练模型(注意agent.brain就是模型):
for epoch in range(agent.EPOCHS):
# running some code using the model.predict function
minibatch = random.sample(agent.memory, agent.BS)
for s, target_vector in minibatch:
agent.brain.fit(x = s, y = [target_vector, np.array([target_value])], epochs = 1)
输出的形状:
policy_output (Dense) (None, 4098) 4724994 flatten_3[0][0]
__________________________________________________________________________________________________
value_output (Activation) (None, 1) 0 dense_4[0][0]
==================================================================================================
此代码:
print(s.shape)
print(target_vector.shape)
返回:
(1, 72, 8, 8)
(4098,)
目标值是一个int
但我有一个错误:
ValueError: All target arrays (y) should have the same number of samples. Got array shapes: [(4098, 1), (1, 1)]
我还试着用一本字典来匹配这个模型,比如
{'policy_output' : target_vector, 'value_output' : np.array([target_value]) }
你能帮我理解我做错了什么吗
目前没有回答
相关问题 更多 >
编程相关推荐