Conversation
hapi/text/text.py
Outdated
| def forward(self, inputs): | ||
| hidden = self.h_0 | ||
| res = [] | ||
| for i in range(inputs.shape[1]): |
There was a problem hiding this comment.
Shape may be dummy for graph mode, for RNN please use RNN api in text.py
There was a problem hiding this comment.
Shape may be dummy for graph mode, for RNN please use
RNNapi in text.py
这个GRU的接口不再写入text.py中了,使用text.py中原有的RNN相关接口搭建网络。
hapi/text/text.py
Outdated
| crf_decode = self.crf_decoding(input=emission, length=lengths) | ||
| return crf_decode, lengths | ||
|
|
||
| class SimpleConvPoolLayer(Layer): |
There was a problem hiding this comment.
As discussed, rename as Conv1DPoolLayer
There was a problem hiding this comment.
As discussed, rename as
Conv1DPoolLayer
Done. Thanks
hapi/text/text.py
Outdated
| return x | ||
|
|
||
|
|
||
| class SimCNNEncoder(Layer): |
There was a problem hiding this comment.
如讨论所述,可以重新命名为CNNEncoder
There was a problem hiding this comment.
如讨论所述,可以重新命名为CNNEncoder
Done,Thanks
hapi/text/text.py
Outdated
| def forward(self, input): | ||
| emb = self.emb_layer(input) | ||
| emb_reshape = fluid.layers.reshape( | ||
| emb, shape=[-1, self.channels, self.seq_len, self.hidden_dim]) |
There was a problem hiding this comment.
感觉最好不要使用固定的seq_len,对于不同batch,seq_len应该允许可变
There was a problem hiding this comment.
感觉最好不要使用固定的seq_len,对于不同batch,seq_len应该允许可变
已更改
hapi/text/text.py
Outdated
| bow_emb = fluid.layers.reduce_sum(emb_reshape, dim=1) | ||
| return bow_emb | ||
|
|
||
| class DynamicGRU(fluid.dygraph.Layer): |
There was a problem hiding this comment.
text.py中已有GRU的接口可以直接使用,对外统一提供一个吧,不然容易引起困惑
There was a problem hiding this comment.
text.py中已有GRU的接口可以直接使用,对外统一提供一个吧,不然容易引起困惑
好的。
hapi/text/text.py
Outdated
| super(SimBOWEncoder, self).__init__() | ||
| self.dict_size = dict_size | ||
| self.bow_dim = bow_dim | ||
| self.seq_len = seq_len |
There was a problem hiding this comment.
感觉BOWEncoder相对简单些可以直接放在模型中,这里可以不提供,另外这里似乎还是会有seq_len的问题
There was a problem hiding this comment.
如果有其他模型需要使用的话这里也可以保留
BOWEncoder只使用了Embedding,感觉由用户自己搭建比较好,不放在text.py中了
hapi/text/text.py
Outdated
| res = fluid.layers.concat(res, axis=1) | ||
| return res | ||
|
|
||
| class SimGRUEncoder(Layer): |
There was a problem hiding this comment.
同上,text.py中已有GRU的接口可以直接使用,对外统一提供一个吧
There was a problem hiding this comment.
同上,text.py中已有GRU的接口可以直接使用,对外统一提供一个吧
好的
hapi/text/text.py
Outdated
| gru = fluid.layers.tanh(gru) | ||
| return gru | ||
|
|
||
| class SimLSTMEncoder(Layer): |
There was a problem hiding this comment.
可以Sim去掉,另外可以参考text.py中已有的GRUEncoder接口提供类似的实现
There was a problem hiding this comment.
可以Sim去掉,另外可以参考text.py中已有的GRUEncoder接口提供类似的实现
好的
hapi/text/text.py
Outdated
| self.emb_dim = emb_dim | ||
| self.lstm_dim = lstm_dim | ||
| self.hidden_dim = hidden_dim | ||
| self.seq_len = seq_len |
|
另外还请在新增API时加上文档 |
已添加 |
hapi/text/text.py
Outdated
| bias_attr (ParamAttr|bool|None): The parameter attribute for the bias of conv.If it is set to False, no bias will be added to the output units. | ||
| If it is set to None or one attribute of ParamAttr, conv2d will create ParamAttr as bias_attr. If the Initializer of the bias_attr is not | ||
| set, the bias is initialized zero. Default: None. | ||
| name(str, optional): The default value is None. Normally there is no need for user to set this property. Default: None |
hapi/text/text.py
Outdated
|
|
||
| class Conv1dPoolLayer(Layer): | ||
| """ | ||
| This interface is used to construct a callable object of the ``Conv1DPoolLayer`` class.The ``Conv1DPoolLayer`` is composed of a ``Conv2D`` and a ``Pool2D`` . |
There was a problem hiding this comment.
这里感觉不要说如何实现,用了Conv2D和Pool2D。而是描述做了什么,做了Conv1D和Pool1D
hapi/text/text.py
Outdated
| Variable | ||
|
|
||
| Example: | ||
| ```python |
There was a problem hiding this comment.
请参考其他添加示例代码的方法 https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/dygraph/nn.py#L143
另外,尽量保证行长度不超过80
hapi/text/text.py
Outdated
|
|
||
| class CNNEncoder(Layer): | ||
| """ | ||
| This interface is used to construct a callable object of the ``CNNEncoder`` class.The ``CNNEncoder`` is composed of a ``Embedding`` and a ``Conv1dPoolLayer`` . |
hapi/text/text.py
Outdated
| class CNNEncoder(Layer): | ||
| """ | ||
| This interface is used to construct a callable object of the ``CNNEncoder`` class.The ``CNNEncoder`` is composed of a ``Embedding`` and a ``Conv1dPoolLayer`` . | ||
| For more details, refer to code examples. The ``CNNEncoder`` layer calculates the output based on the input, dict_size and emb_dim, filter_size, num_filters, |
There was a problem hiding this comment.
要描述清楚这个接口做了什么,按照这里的描述无法区分这个CNNEncoder是做了多层CNN的堆叠还是多个CNN的并行
hapi/text/text.py
Outdated
| Return: | ||
| 3-D Tensor, the result of input after embedding and conv1dPoollayer | ||
|
|
||
| Return Type: |
There was a problem hiding this comment.
class文档注释可以不用添加return内容
| use_cudnn=self.use_cudnn | ||
| ) for i in range(layer_num)]) | ||
|
|
||
| def forward(self, input): |
There was a problem hiding this comment.
为class的method添加文档,说明输入参数和返回内容,上面那个Conv1DPoolLayer类似
|
另外,请使用pre-commit |
|
后续可以加入stack的CNNEncoder,以及支持param_attr传入 |
No description provided.