what is a recurrent neural network?
3 things you need to know
a recurrent neural network (rnn) is a network architecture for deep learning that predicts on time-series or sequential data.
rnns are particularly effective for working with sequential data that varies in length and solving problems such as natural signal classification, language processing, and video analysis.
how rnns work
a recurrent neural network (rnn) is a deep learning structure that uses past information to improve the performance of the network on current and future inputs. what makes an rnn unique is that the network contains a hidden state and loops. the looping structure allows the network to store past information in the hidden state and operate on sequences.
how does the rnn know how to apply the past information to the current input? the network has two sets of weights: one for the hidden state vector and one for the inputs. during training, the network learns weights for both the inputs and the hidden state. when implemented, the output is based on the current input, as well as the hidden state, which is based on previous inputs.
lstm
in practice, simple rnns experience a problem with learning longer term dependencies. rnns are commonly trained through backpropagation, where they can experience either a “vanishing” or “exploding” gradient problem. these problems cause the network weights to either become very small or very large, limiting the effectiveness of learning long-term relationships.
a special type of rnn that overcomes this issue is the long short-term memory (lstm) network. lstm networks use additional gates to control what information in the hidden cell makes it to the output and the next hidden state. this allows the network to learn long-term relationships more effectively in the data. lstms are a commonly implemented type of rnn.
a bidirectional lstm learns bidirectional dependencies between time steps of time-series or sequence data. these dependencies can be useful when you want the network to learn from the complete time series at each time step. another rnn variant that learns longer term dependencies is the gated rnn. you can train and work with bidirectional lstms and gated rnns in matlab®.
get started with rnn examples in matlab
why rnns matter
rnns are a key technology in applications such as:
signal processing
signals are naturally sequential data, as they are often collected from sensors over time. automatic and on large signal data sets allow prediction in real time. raw signals data can be fed into deep networks or preprocessed to focus on specific features, such as frequency components. feature extraction can greatly improve network performance.
text analytics
language is naturally sequential, and pieces of text vary in length. rnns are a great tool for natural language processing tasks, such as , text generation, , and sentiment analysis (categorizing the meaning of words and phrases), because they can learn to contextualize words in a sentence.
when should you use rnns?
consider using rnns when you work with sequence and time-series data for classification and regression tasks. rnns also work well on videos because videos are essentially a sequence of images. similar to working with signals, it helps to do feature extraction before feeding the sequence into the rnn. leverage cnns (e.g., googlenet) for feature extraction on each frame.
explore matlab examples using rnns with text, signals, and videos.
rnns with matlab
using matlab with deep learning toolbox™ enables you to design, train, and deploy rnns. using text analytics toolbox™ or signal processing toolbox™ allows you to apply rnns to text or signal analysis.
design and train networks
you can create and train rnns programmatically with a few lines of matlab code. use recurrent layers (, , , and ) to build rnns. use a in an rnn network to map words into numeric sequences.
you can also create and train rnns interactively using the deep network designer app. monitor training with plots of accuracy, loss, and validation metrics.
you can deploy your trained rnn on embedded systems, enterprise systems, fpga devices, or the . you can also generate code from intel®, nvidia®, and arm® libraries to create deployable rnns with high-performance inference speed.