6
$\begingroup$

I'm trying to build a neural network with an unconventional architecture and a having trouble figuring out how. Usually we have connections like so, where $X=$ input, $H=$ hidden layer, $Y=$ output layer:

$X_t \rightarrow H_t \rightarrow Y_t$

and

$H_t \rightarrow H_{t+1}$

Normal Tensorflow or Keras nodes build above, where we end up with weight matrices connecting each component, i.e. $W_{xh}, W_{hh}, W_{hy}$.

I would also like to introduce a connection:

$Y_t \rightarrow H_{t+1}$, defined by a new weight matrix $W_{yh}$.

I have looked at the Tensorflow and Keras implementations and there is a self.kernel ($W_{xh}$) and self.recurrent_kernel ($W_{hh}$), where the second is defined in terms of the previous hidden node's output prev_output = states[0], defined here. Does anyone have a sense of how to access the output of the output layer in the subsequent step? Is it states[1]? How are states defined, and where is that documented?

Thanks for any insight you can give!

Edit: Before anyone asks yes, I recognize that such a connection is not strictly necessary. I am trying to understand information flow through network nodes.

$\endgroup$
1
  • $\begingroup$ In case anyone is wondering, I have found a stop-gap by editing the code here[0]. This is written in pure tensorflow and I had to update the code a bit so it would work with the newest version. It also (currently) uses basic RNN cells and loops are unrolled by default, but that's OK for the problem I'm trying to solve. Hope it helps someone. I would LOVE to find a way to do this in Keras if possible. [0] medium.com/@erikhallstrm/hello-world-rnn-83cd7105b767 $\endgroup$
    – tom
    Commented Nov 19, 2017 at 6:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.