强化学习:Q学习与演员-评论家方法
1. Q学习与Keras
1.1 构建双输入网络
在之前,我们通常使用Keras的Sequential模型来定义神经网络,以下是一个使用顺序API定义模型的示例:
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(32, input_shape=(19, 19)))
model.add(Dense(24))
Keras还提供了另一种定义神经网络的API——函数式API。函数式API提供了顺序API功能的超集,我们可以用函数式风格重写任何顺序网络,还能创建无法用顺序风格描述的复杂网络。
下面是使用函数式风格创建与上述顺序API定义相同网络的示例:
from keras.models import Model
from keras.layers import Dense, Input
model_input = Input(shape=(19, 19))
hidden_layer = Dense(32)(model_input)
output_layer = Dense(24)(hidden_layer)
model = Model(inputs=[model_input], outputs=[output_layer])
这两个模型是相同的。顺序AP
超级会员免费看
订阅专栏 解锁全文
1896

被折叠的 条评论
为什么被折叠?



