Browse Source

maybe we should add r before all """ beginnings

tags/v0.4.10
ChenXin 5 years ago
parent
commit
42b621956e
2 changed files with 13 additions and 9 deletions
  1. +12
    -7
      fastNLP/io/loader/matching.py
  2. +1
    -2
      fastNLP/modules/encoder/attention.py

+ 12
- 7
fastNLP/io/loader/matching.py View File

@@ -450,21 +450,26 @@ class BQCorpusLoader(Loader):




class LCQMCLoader(Loader): class LCQMCLoader(Loader):
"""
别名:
r"""
数据集简介:句对匹配(question matching) 数据集简介:句对匹配(question matching)
原始数据为: 原始数据为:
'喜欢打篮球的男生喜欢什么样的女生\t爱打篮球的男生喜欢什么样的女生\t1\n'
'晚上睡觉带着耳机听音乐有什么害处吗?\t孕妇可以戴耳机听音乐吗?\t0\n'
读取后的Dataset将具有以下的数据结构:

.. code-block:: text
'喜欢打篮球的男生喜欢什么样的女生\t爱打篮球的男生喜欢什么样的女生\t1\n'
'晚上睡觉带着耳机听音乐有什么害处吗?\t孕妇可以戴耳机听音乐吗?\t0\n'
读取后的Dataset将具有以下的数据结构
.. csv-table:: .. csv-table::
:header: "raw_chars1", "raw_chars2", "target" :header: "raw_chars1", "raw_chars2", "target"
"喜欢打篮球的男生喜欢什么样的女生?", "爱打篮球的男生喜欢什么样的女生?", "1" "喜欢打篮球的男生喜欢什么样的女生?", "爱打篮球的男生喜欢什么样的女生?", "1"
"晚上睡觉带着耳机听音乐有什么害处吗?", "妇可以戴耳机听音乐吗?", "0" "晚上睡觉带着耳机听音乐有什么害处吗?", "妇可以戴耳机听音乐吗?", "0"
"...", "...", "..." "...", "...", "..."

""" """


def __init__(self): def __init__(self):


+ 1
- 2
fastNLP/modules/encoder/attention.py View File

@@ -152,8 +152,7 @@ class BiAttention(nn.Module):
:param torch.Tensor premise_mask: [batch_size, a_seq_len] :param torch.Tensor premise_mask: [batch_size, a_seq_len]
:param torch.Tensor hypothesis_batch: [batch_size, b_seq_len, hidden_size] :param torch.Tensor hypothesis_batch: [batch_size, b_seq_len, hidden_size]
:param torch.Tensor hypothesis_mask: [batch_size, b_seq_len] :param torch.Tensor hypothesis_mask: [batch_size, b_seq_len]
:return: torch.Tensor attended_premises: [batch_size, a_seq_len, hidden_size]
torch.Tensor attended_hypotheses: [batch_size, b_seq_len, hidden_size]
:return: torch.Tensor attended_premises: [batch_size, a_seq_len, hidden_size] torch.Tensor attended_hypotheses: [batch_size, b_seq_len, hidden_size]
""" """
similarity_matrix = premise_batch.bmm(hypothesis_batch.transpose(2, 1) similarity_matrix = premise_batch.bmm(hypothesis_batch.transpose(2, 1)
.contiguous()) .contiguous())


Loading…
Cancel
Save