liu-nlper / NER-LSTM-CRF

An easy-to-use named entity recognition (NER) toolkit, implemented the Bi-LSTM+CRF model in tensorflow.
347 stars 117 forks source link

关于CNN的几个问题 #25

Open shuaihuaiyi opened 6 years ago

shuaihuaiyi commented 6 years ago

1、3D卷积核的shape中,那个恒定为1的维度代表了什么呢?之前您使用tf.expand_dims将输入的维度增加了1,这两者有关吗?kernel_size中的那些参数是根据什么来进行排列的呢? 2、tf.contrib.layers.conv3d提供了默认参数activation_fn=tf.nn.relu, 为什么之后还要手动进行一次激活? 3、with语句中的最后一行scope.reuse_variables()有什么作用呢?执行完这条语句就会进入下一次循环,构造新的scope,我有点想不通

shuaihuaiyi commented 6 years ago

另外很多论文里的CNN都是从两侧进行padding的(比如Named Entity Recognition with Bidirectional LSTM-CNNs和End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF)这个项目似乎是只从末尾进行padding,这种是无所谓的吗?

深度学习刚刚入门不久,问题比较多,麻烦您啦

liu-nlper commented 6 years ago

你好:

最近忙于毕业材料的事,所以没时间回复。

  1. CNN padding的问题:CNN在两侧padding是为了保证卷积得到的feature map与输入一致,我们一般用窄卷积(narrow conv)就行了;

  2. 3D卷积核的shape中,1表示的是通道数,这个值也不是恒定为1,例如RGP图像的通道就是3;或者层叠的卷积层,第i层的输入通道即第i-1层的输出通道数(i-1层的卷积核数量);参数的顺序参考官方文档;

  3. 默认参数activation_fn=tf. nn.relu,当时我用的版本可能没有默认激活函数,如果默认是relu的话,那外层就没必要再激活一次了;

  4. scope.reuse_variables()应该是为了重用变量,具体不太清楚。

另外,这个库不打算再维护了,现在开始用pytorch了,可以参考这个功能更全的版本:https://github.com/liu-nlper/SLTK

祝好

On Thu, May 24, 2018 at 3:36 PM, 率怀一 notifications@github.com wrote:

另外很多论文里的CNN都是从两侧进行padding的(比如Named Entity Recognition with Bidirectional LSTM-CNNs和End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF) 这个项目似乎是只从末尾进行padding,这种是无所谓的吗?

深度学习刚刚入门不久,问题比较多,麻烦您啦

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/liu-nlper/NER-LSTM-CRF/issues/25#issuecomment-391618869, or mute the thread https://github.com/notifications/unsubscribe-auth/ASWWilgjQIOs8_oXwkHCxL6xtWSddpaXks5t1mMKgaJpZM4UAq6V .

shuaihuaiyi commented 6 years ago

在官方文档只有这样的说明

kernel_size: A sequence of N positive integers specifying the spatial dimensions of the filters. Can be a single integer to specify the same value for all spatial dimensions.

我理解这里对单词的卷积是这样的:首先一个单词表示成字符向量的序列,shape应该是【单词里的字符数量,字符向量的维度】,卷积核的shape应该是【超参数指定的卷积核长度,字符向量的维度】。如果字符向量是列向量,那么卷积核应当只沿着行进行滑动,它覆盖了所有的列,所以不会在这一方向进行滑动。是不是没有必要加入channel呢?加入channel之后,现在输入单词的shape是【单词里的字符数量,字符向量的维度,通道数(1)】,而卷积核的shape是【通道数(1),超参数指定的卷积核长度,字符向量的维度】,为什么把通道数移到最前面了呢?在tf.nn.conv*d系列API里都是按顺序写的,而tf.contrib.layers.conv2d的API文档里只有上面的说明,所以有些不理解