Skip to content

Commit cc30fad

Browse files
Merge pull request #534 from peterzhang2029/dssm_fix
Fix the output of cnn in DSSM.
2 parents 86f462a + 703ed80 commit cc30fad

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

dssm/README.cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def create_cnn(self, emb, prefix=''):
131131

132132
conv_3 = create_conv(3, self.dnn_dims[1], "cnn")
133133
conv_4 = create_conv(4, self.dnn_dims[1], "cnn")
134-
return conv_3, conv_4
134+
return paddle.layer.concat(input=[conv_3, conv_4])
135135
```
136136

137137
CNN 接受词向量序列,通过卷积和池化操作捕捉到原始句子的关键信息,最终输出一个语义向量(可以认为是句子向量)。
@@ -263,7 +263,7 @@ Pairwise Rank复用上面的DNN结构,同一个source对两个target求相似
263263

264264
## 执行训练
265265

266-
可以直接执行 `python train.py -y 0 --model_arch 0` 使用 `./data/classification` 目录里的实例数据来测试能否直接运行训练分类FC模型。
266+
可以直接执行 `python train.py -y 0 --model_arch 0 --class_num 2` 使用 `./data/classification` 目录里的实例数据来测试能否直接运行训练分类FC模型。
267267

268268
其他模型结构也可以通过命令行实现定制,详细命令行参数请执行 `python train.py --help`进行查阅。
269269

dssm/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def create_cnn(self, emb, prefix=''):
107107

108108
conv_3 = create_conv(3, self.dnn_dims[1], "cnn")
109109
conv_4 = create_conv(4, self.dnn_dims[1], "cnn")
110-
return conv_3, conv_4
110+
return paddle.layer.concat(input=[conv_3, conv_4])
111111
```
112112

113113
CNN accepts the word sequence of the embedding table, then process the data by convolution and pooling, and finally outputs a semantic vector.
@@ -240,12 +240,12 @@ The example of this format is as follows.
240240

241241
## Training
242242

243-
We use `python train.py -y 0 --model_arch 0` with the data in `./data/classification` to train a DSSM model for classification. The paremeters to execute the script `train.py` can be found by execution `python infer.py --help`. Some important parameters are:
243+
We use `python train.py -y 0 --model_arch 0 --class_num 2` with the data in `./data/classification` to train a DSSM model for classification. The paremeters to execute the script `train.py` can be found by execution `python infer.py --help`. Some important parameters are:
244244

245245
- `train_data_path` Training data path
246246
- `test_data_path` Test data path, optional
247247
- `source_dic_path` Source dictionary path
248-
- `target_dic_path` 目Target dictionary path
248+
- `target_dic_path` Target dictionary path
249249
- `model_type` The type of loss function of the model: classification 0, sort 1, regression 2
250250
- `model_arch` Model structure: FC 0,CNN 1, RNN 2
251251
- `dnn_dims` The dimension of each layer of the model is set, the default is `256,128,64,32`,with 4 layers.

dssm/network_conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ def create_conv(context_len, hidden_size, prefix):
146146
pool_bias_attr=ParamAttr(name=key + "_pool.b"))
147147
return conv
148148

149-
logger.info("create a sequence_conv_pool which context width is 3")
149+
logger.info("create a sequence_conv_pool whose context width is 3.")
150150
conv_3 = create_conv(3, self.dnn_dims[1], "cnn")
151-
logger.info("create a sequence_conv_pool which context width is 4")
151+
logger.info("create a sequence_conv_pool whose context width is 4.")
152152
conv_4 = create_conv(4, self.dnn_dims[1], "cnn")
153153

154-
return conv_3, conv_4
154+
return paddle.layer.concat(input=[conv_3, conv_4])
155155

156156
def create_dnn(self, sent_vec, prefix):
157157
# if more than three layers, than a fc layer will be added.

0 commit comments

Comments
 (0)