How does a recurrent neural network work?
循环神经网络如何运作？
The following image shows a diagram of an RNN.
RNNs are made of neurons: data-processing nodes that work together to perform complex tasks. The neurons are organized as input, output, and hidden layers. The input layer receives the information to process, and the output layer provides the result. Data processing, analysis, and prediction take place in the hidden layer.
Hidden layer
RNNs work by passing the sequential data that they receive to the hidden layers one step at a time. However, they also have a self-looping or recurrent workflow: the hidden layer can remember and use previous inputs for future predictions in a short-term memory component. It uses the current input and the stored memory to predict the next sequence.
For example, consider the sequence: Apple is red. You want the RNN to predict red when it receives the input sequence Apple is. When the hidden layer processes the word Apple, it stores a copy in its memory. Next, when it sees the word is, it recalls Apple from its memory and understands the full sequence: Apple is for context. It can then predict red for improved accuracy. This makes RNNs useful in speech recognition, machine translation, and other language modeling tasks.
Read about machine translation
Training
Machine learning (ML) engineers train deep neural networks like RNNs by feeding the model with training data and refining its performance. In ML, the neuron's weights are signals to determine how influential the information learned during training is when predicting the output. Each layer in an RNN shares the same weight.
ML engineers adjust weights to improve prediction accuracy. They use a technique called backpropagation through time (BPTT) to calculate model error and adjust its weight accordingly. BPTT rolls back the output to the previous time step and recalculates the error rate. This way, it can identify which hidden state in the sequence is causing a significant error and readjust the weight to reduce the error margin.
Read about machine learning
下图为 RNN 示意图。
RNN 由神经元组成，神经元是协同工作以执行复杂任务的数据处理节点。神经元分为输入层、输出层和隐藏层。输入层接收要处理的信息，输出层提供结果。数据处理、分析和预测在隐藏层中进行。
隐藏层
RNN 的工作原理是将接收到的顺序数据逐步传递给隐藏层。但是，RNN 还有一个自循环或循环的工作流程：隐藏层可以在短期记忆组件中记住之前的输入并使用这些输入进行未来的预测。它使用当前输入和存储的记忆来预测下一个序列。
例如，考虑以下序列：Apple is red。您想让 RNN 在接收输入序列 Apple is 时预测 red。当隐藏层处理 Apple 一词时，会在记忆中存储一份副本。随后，当接收到 is 一词时，它会从记忆中调取 Apple，并根据上下文理解完整序列：Apple is。然后，它可以预测 red 以提高准确性。这使得 RNN 在语音识别、机器翻译和其他语言建模任务中颇为有用。
了解机器翻译
培训
机器学习（ML）工程师通过向模型提供训练数据并优化其性能来训练 RNN 等深度神经网络。在机器学习中，神经元的权重是确定训练期间学到的信息在预测输出时影响力的信号。RNN 中每一层权重相同。
机器学习工程师可调整权重以提高预测准确性。他们使用一种称为随时间反向传播（BPTT）的技术来计算模型误差并相应地调整其权重。BPTT 将输出回滚到前一个时间步长并重新计算错误率。这样，它便可以识别序列中哪个隐藏状态导致了重大错误，并重新调整权重以减少误差幅度。
了解机器学习