【发布时间】:2020-04-21 06:37:53
【问题描述】:
我试图在 Keras 中重新创建 this architecture 以解决 XOR 问题,其中权重连接输入(二维数组)和输出(标量)。我知道用全连接的2,2,1架构可以解决异或问题,但是不知道如何在Keras中实现这个架构。
我阅读了文档并研究了 SO,但似乎找不到解决方案。以下代码显示了我到目前为止所做的事情。我的主要问题是如何连接隐藏层和输出层。
input1 = keras.layers.Input(shape=(2,)) # input
hidden_layer = keras.layers.Dense(1, activation='tanh')(input1) # linking the input with the hidden layer
output1 = keras.layers.Dense(1, activation='tanh')(input1) # linking the input with the output layer
# The code for connecting hidden and output layer should probably go here #
model = keras.models.Model(inputs=input1, outputs=outpu1)
model.compile(...)
【问题讨论】:
标签: python keras neural-network keras-layer