循环神经网络与长短期记忆网络:原理、应用与比较
1. 循环神经网络(RNN)基础
循环神经网络(RNN)与传统前馈神经网络不同,在解决时间序列任务方面更强大。RNN 有多种形式,包括一对一(文本生成)、多对一(顺序图像分类)、一对多(图像字幕)和多对多(机器翻译)。
1.1 从传统网络到 RNN
从传统前馈神经网络结构推导 RNN,假设存在输入和输出序列,设计能表示该序列的计算图。此计算图会产生一系列函数副本,应用于序列中的每个输入 - 输出元组。将该模型推广到序列中的任意单个时间步 t,就能得到 RNN 的基本计算图。下面是计算 RNN 输出的代码示例:
# Train score (unnormalized) values and predictions (normalized)
y_scores, y_predictions = [],[]
# These will be iteratively used within num_unroll
# steps of calculation
next_h_state = prev_train_h
next_s_state = prev_train_s
# Appending the calculated state outputs of RNN for
# each step in the num_unroll steps
next_h_states_unrolled, next_s_states_unrolled = [],[]
# Calculating the output of the RNN for num_unroll step
超级会员免费看
订阅专栏 解锁全文
1247

被折叠的 条评论
为什么被折叠?



