Varun Sharma

Logo

View the Project on GitHub netgvarun2012/portfolio

RNN and LSTMs

While FeedForward netweorks can accomodate arbitrary sized sequences through the use of vector addition and concatenation (CBOW), such representations are quite limited and disregard the order of the features. Recurrent Neural Networks allow representing arbitrarily sized sequential inputs in a fixed-size vectors, paying attention to the structured properties of the inputs.

RNNs, particularly ones with gated architectures such as the LSTM and the GRU, are very powerful at capturing statistical regularities in sequential inputs.

RNNs

Hidden These units are called “hidden” in the sense that they interact exclusively with other nodes internal to the network, and not the outside world!.

Imagine that there is a sequential input to be processed, and some clock which regulates presentation of the input to the network. Processing would then consist of the following sequence of events:

  1. At time t, the input units receive the first input in the sequence.
  2. Both the input units and context units activate the hidden units.
  3. The hidden units then feed forward to activate the output units.
  4. The hidden units also feed back to activate the context units.
  5. Output is compared with a teacher input, and backpropogation of error is used to adjust the connection stengths incrementally.
  6. At time step, t+1, the above sequence is repeated.

    image

    image

    image

RNN as a Generator

image

RNN as a Conditional Generator

image

What kind of information can be encoded in the context c?

RNN as an ENCODER-DECODER

Another popular approach takes c to be itself a sequence, most commonly a piece of text. This gives rise to the sequence to sequence conditioned generation framework, also called the encoder-decoder framework

a) The encoder summarizes the source sentence as a vector c.

b) The decoder RNN is then used to predict (using a language modeling objective) the target sequence words conditioned on the previously predicted words as well as the encoded sentence c.

c) The encoder and decoder RNNs are trained jointly.

image

image

Problems with RNN Encoder-Decoder Network

https://arxiv.org/pdf/1409.1259.pdf

The encoder extracts a fixed-length vector representation from a variable-length input sentence, and from this representation the decoder generates a correct, variable-length target translation. However, this mechanism runs into problems with long source sentences.

image

Solution NEURAL MACHINE TRANSLATION BY JOINTLY LEARNING TO ALIGN AND TRANSLATE

image

image

image

image

More info on the attention mechanism.

Weight Matrix

image

The concept of weight matrix sharing in Recurrent Neural Networks (RNNs) primarily revolves around the idea of using the same set of weights across different time steps or iterations of the network.

In traditional feedforward neural networks, each layer has its unique set of weights connecting the neurons in one layer to the next. However, in RNNs, weight matrix sharing refers to the reusability of the same weights across multiple time steps. This sharing of weights allows the network to maintain memory and capture temporal dependencies in sequential data.

Here’s what makes a RNN recurrent: it uses the same weights for each step. More specifically, a typical vanilla RNN uses only 3 sets of weights to perform its calculations:

image

image

image

image

Solving Vanishing Gradient problem using LSTMs

image

image

image

image

image

image