# Is there a neural network that accepts both the current input and previous output?

I am quite new to neural networks. I am trying to implement in Python a neural network having only one hidden layer with $$N$$ neurons and $$1$$ output layer.

The point is that I am analyzing time series and would like to use the output layer as the input of the next unit: by feeding the network with the input at time $$t-1$$ I obtain the output $$O_{t-1}$$ and, in the next step, I would like to use both the input at time $$t$$ and $$O_{t-1}$$, introducing a sort of auto-regression. I read that recurrent neural network are suitable to address this issue.

Anyway I cannot imagine how to implement a network in Keras that involves multilayer recurrence: all the references I found are linked to using the output of a layer as input of the same layer in the next step. Instead, I would like to include the output of the last layer (the output layer) in the inputs of the first hidden layer.

• You originally tagged your post with "recurrent neural networks", so I guess you are aware of them and know what they are used for. If yes, I don't understand the purpose of this question. – nbro Aug 5 '20 at 22:07
• Sure, after a couple of days spent searching I came across "recurrent neural networks" and I have read some things about that. I just cannot understand how can such a RNN be implemented in Python. All the information I found are about networks in which the output (e.g. the hidden states) of a layer is used as input of the same layer; instead, I would like to create a recurrent structure that involves more layers. – piotor Aug 5 '20 at 22:20
• Well, you should have specified that in your question. I suggest that you edit your post to clarify that you are already aware of RNNs and what your question really is. – nbro Aug 5 '20 at 22:20
• Sorry, I think you're right. I'll do it – piotor Aug 5 '20 at 22:22
• @piotor Here's an example implementation of an LSTM, a popular type of RNN, in python: github.com/nicodjimenez/lstm/blob/master/lstm.py – Recessive Aug 6 '20 at 0:14