diff --git a/understand_sentiment/README.md b/understand_sentiment/README.md
index 52025aaa04b1c4aababf15ed368fe7cc3e4eafa6..40a109632122a9e835bbd86d218f9d79c4761219 100644
--- a/understand_sentiment/README.md
+++ b/understand_sentiment/README.md
@@ -28,7 +28,7 @@ $$c=[c_1,c_2,\ldots,c_{n-h+1}]$$
其中$c \in \mathbb{R}^{n-h+1}$。接下来我们对feature map采用max pooling over time操作得到此filter对应的特征:
$$\hat c=max(c)$$
即,$\hat c$是feature map中所有元素的最大值。pooling机制自动处理了句子长度不一的问题。在实际应用中,我们会使用多个filter来处理句子,窗口大小相同的filters堆叠起来形成一个矩阵(上文中的单个filter参数$w$相当于矩阵的某一行),这样可以更高效的完成运算。另外,我们也可使用窗口大小不同的filters来处理句子,最后,将所有filters得到的特征拼接起来即为文本的定长向量表示。对于文本分类问题,将其连接至softmax即构建出完整的模型。
-
可以将上文所述的卷积神经网络的filter理解为特定语义n-gram的探测器(detector),其优点是避免了传统n-gram的高维稀疏表示问题,运算和训练速度十分快,准确率也很高(ref)。但是它难以扩展为深层文本卷积网络,基于此,N. Kalchbrenner, et al.(2014)提出了k-max pooling,使用其可以构建出深层文本卷积网络,有兴趣的读者可以参考相关文献。
+
### 循环神经网络
#### 简单的循环神经网络
循环神经网络是一种能对序列数据进行精确建模的有力工具。实际上,循环神经网络的理论计算能力是图灵完备的(Siegelmann, H. T. and Sontag, E. D., 1995)。
@@ -482,4 +482,4 @@ Loading parameters from model_output/pass-00002/
## 总结
-## 参考文献
\ No newline at end of file
+## 参考文献
diff --git a/understand_sentiment/sentiment_net.py b/understand_sentiment/sentiment_net.py
index 1a92d655148f7ed7b5085a7237e795bc05f8e7fe..7ab503135d4d75e8ecaef0fa1ad440c125e57e50 100644
--- a/understand_sentiment/sentiment_net.py
+++ b/understand_sentiment/sentiment_net.py
@@ -56,6 +56,7 @@ def sentiment_data(data_dir=None,
return dict_dim, class_dim
+
def convolution_net(input_dim,
class_dim=2,
emb_dim=128,
@@ -65,7 +66,8 @@ def convolution_net(input_dim,
emb = embedding_layer(input=data, size=emb_dim)
conv_3 = sequence_conv_pool(input=emb, context_len=3, hidden_size=hid_dim)
conv_4 = sequence_conv_pool(input=emb, context_len=4, hidden_size=hid_dim)
- output = fc_layer(input=[conv_3,conv_4], size=class_dim, act=SoftmaxActivation())
+ output = fc_layer(
+ input=[conv_3, conv_4], size=class_dim, act=SoftmaxActivation())
if not is_predict:
lbl = data_layer("label", 1)
diff --git a/understand_sentiment/trainer_config.py b/understand_sentiment/trainer_config.py
index 42deac405921fe229550d51e9b83300fbab55f1a..b327d09f269bfbd5849b1f2e27b2619f62ff5d37 100644
--- a/understand_sentiment/trainer_config.py
+++ b/understand_sentiment/trainer_config.py
@@ -37,4 +37,4 @@ settings(
stacked_lstm_net(
dict_dim, class_dim=class_dim, stacked_num=3, is_predict=is_predict)
# bidirectional_lstm_net(dict_dim, class_dim=class_dim, is_predict=is_predict)
-# convolution_net(dict_dim, class_dim=class_dim, is_predict=is_predict)
\ No newline at end of file
+# convolution_net(dict_dim, class_dim=class_dim, is_predict=is_predict)