@@ -58,7 +58,10 @@ | |||||
2 DataSet与预处理 | 2 DataSet与预处理 | ||||
常见的预处理有如下几种 | 常见的预处理有如下几种 | ||||
2.1 从某个文本文件读取内容 # TODO 引用DataLoader | |||||
2.1 从某个文本文件读取内容 # | |||||
.. todo:: | |||||
引用DataLoader | |||||
Example:: | Example:: | ||||
@@ -221,8 +221,7 @@ class CrossEntropyLoss(LossBase): | |||||
""" | """ | ||||
def __init__(self, pred=None, target=None, padding_idx=-100): | def __init__(self, pred=None, target=None, padding_idx=-100): | ||||
# TODO 需要做一些检查,F.cross_entropy在计算时,如果pred是(16, 10 ,4), target的形状按道理应该是(16, 10), 但实际却需要 | |||||
# TODO (16, 4) | |||||
# TODO 需要做一些检查,F.cross_entropy在计算时,如果pred是(16, 10 ,4), target的形状按道理应该是(16, 10), 但实际需要(16,4) | |||||
super(CrossEntropyLoss, self).__init__() | super(CrossEntropyLoss, self).__init__() | ||||
self._init_param_map(pred=pred, target=target) | self._init_param_map(pred=pred, target=target) | ||||
self.padding_idx = padding_idx | self.padding_idx = padding_idx | ||||
@@ -47,7 +47,6 @@ class BaseLoader(object): | |||||
class DataLoaderRegister: | class DataLoaderRegister: | ||||
# TODO 这个类使用在何处? | |||||
_readers = {} | _readers = {} | ||||
@classmethod | @classmethod | ||||
@@ -64,3 +63,5 @@ class DataLoaderRegister: | |||||
if read_fn_name in cls._readers: | if read_fn_name in cls._readers: | ||||
return cls._readers[read_fn_name] | return cls._readers[read_fn_name] | ||||
raise AttributeError('no read function: {}'.format(read_fn_name)) | raise AttributeError('no read function: {}'.format(read_fn_name)) | ||||
# TODO 这个类使用在何处? |
@@ -12,7 +12,8 @@ from ..utils import initial_parameter | |||||
class DotAttention(nn.Module): | class DotAttention(nn.Module): | ||||
""" | """ | ||||
TODO | |||||
.. todo:: | |||||
补上文档 | |||||
""" | """ | ||||
def __init__(self, key_size, value_size, dropout=0): | def __init__(self, key_size, value_size, dropout=0): | ||||
super(DotAttention, self).__init__() | super(DotAttention, self).__init__() | ||||
@@ -70,7 +70,10 @@ def initial_parameter(net, initial_method=None): | |||||
def get_embeddings(init_embed): | def get_embeddings(init_embed): | ||||
""" | """ | ||||
得到词嵌入 TODO | |||||
得到词嵌入 | |||||
.. todo:: | |||||
补上文档 | |||||
:param init_embed: 单词词典, 可以是 tuple, 包括(num_embedings, embedding_dim), 即 | :param init_embed: 单词词典, 可以是 tuple, 包括(num_embedings, embedding_dim), 即 | ||||
embedding的大小和每个词的维度. 也可以传入 nn.Embedding 对象, | embedding的大小和每个词的维度. 也可以传入 nn.Embedding 对象, | ||||