-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Parallelizable Stack Long Short-Term Memory
StackLSTM 有个栈 H, 传统的 LSTM 根据
输入数据 x_t , 栈数据 h_j
actions 包括至少
- Push:
$h_{p(H)}$ , 与$x_t$ 计算$h_{p(H)+1}$ ,$p(H) ,+!!= 1$ - Pop:
$p(H) ,-!!=1$
这个设计有点奇怪啊, 首先 push 使用栈顶的数据,把新数据压栈。
如果一直 push,计算到最后,栈顶的结果和 传统 LSTM 相同。
如果几次 push 之后,pop 一次,实际上就把栈顶的数据给扔了。 再 push,岂不相当于把输入数据中的某个 x 给删除了?
用 Push 和 Pop 可以构建 dependency Tree ?
observation1, push 和 pop 可以统一 成
$p(H) ,+!!= \mathit{op}$ ,observation2, 栈顶以外的元素不会被读到. 所以(无效)计算可以做了写在栈外.
(居然能煞有介事地写成 observation..)
总之就是消除 if else 语句, 方便并行化. 把对 stackLSTM 的并行在 pytorch 上做了实现.
实验中与 dynet进行对比时, dynet 在batch size 增加时其训练速度居然没有变化? 是不是数据出了问题?
在我看来,真的没多少贡献啊,不过也只是一篇workshop.
代码 https://github.com/shuoyangd/hoolock
hoolock/model
utils.tensor.py 中 batch 方法, 将所有句子从短到长排序(这一步可选), 分成每 batch_size 个句子一组, 每组按照最长的句子 padding
Chris Dyer, Miguel Ballesteros, Wang Ling, Austin
Matthews, and Noah A. Smith. 2015. Transitionbased dependency parsing with stack long shortterm memory. ACL 2015,
这篇要看. StackLSTM
StackLSTM
StackLSTM 用于 Transition-based dependency parsing, 将parsing 问题看做是对 shift 或 reduce 的选择.
这种 parsing 6822 的好处是相比基于图,语法的方法, 速度更快, 复制度为句子长度线性.
对于如何选择 transition , 已经有通过神经网络的方法, 本文将其修改为, 根据 parser 的所有状态来学习生成 transition
所有状态:
- the complete input buffer
- the complete history of parser actions
- and the complete contents of the stack of partially constructed syntactic structures.
之前的做法则使用了 input buffer 中的下面几个词, stack 的top 几个元素.
push 叫 reading, pop 叫 forgetting, 也就是说之前的猜想差不多. 这个并不是 tree 类型的.
并行 stackLSTM 的描述错了, 应该有两个指针, 一个指向栈顶, 用于写数据, xxx
contents are never overwritten,
push always adds a new entry at the end of
the list that contains a back-pointer to the previous
top, and pop only updates the stack pointer.
其他
benchmarks with other dynamic frameworks: knet.jl 的一个讨论,
efficent TreeRNN in TensorFlow
在TensorFlow 上对比两种实现, 一种动态构建计算图, 一种使用 tf.while 静态图.
得出结论, 使用静态图, 训练快16倍, 推理快 8 倍.
静态构建图, 然后在图上进行算子合并?