Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Conversation

@jinyuKING
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Apr 27, 2020

CLA assistant check
All committers have signed the CLA.

def forward(self, inputs):
hidden = self.h_0
res = []
for i in range(inputs.shape[1]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shape may be dummy for graph mode, for RNN please use RNN api in text.py

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shape may be dummy for graph mode, for RNN please use RNN api in text.py

这个GRU的接口不再写入text.py中了,使用text.py中原有的RNN相关接口搭建网络。

crf_decode = self.crf_decoding(input=emission, length=lengths)
return crf_decode, lengths

class SimpleConvPoolLayer(Layer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, rename as Conv1DPoolLayer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, rename as Conv1DPoolLayer

Done. Thanks

return x


class SimCNNEncoder(Layer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如讨论所述,可以重新命名为CNNEncoder

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如讨论所述,可以重新命名为CNNEncoder

Done,Thanks

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])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉最好不要使用固定的seq_len,对于不同batch,seq_len应该允许可变

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉最好不要使用固定的seq_len,对于不同batch,seq_len应该允许可变

已更改

bow_emb = fluid.layers.reduce_sum(emb_reshape, dim=1)
return bow_emb

class DynamicGRU(fluid.dygraph.Layer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text.py中已有GRU的接口可以直接使用,对外统一提供一个吧,不然容易引起困惑

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text.py中已有GRU的接口可以直接使用,对外统一提供一个吧,不然容易引起困惑

好的。

super(SimBOWEncoder, self).__init__()
self.dict_size = dict_size
self.bow_dim = bow_dim
self.seq_len = seq_len
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉BOWEncoder相对简单些可以直接放在模型中,这里可以不提供,另外这里似乎还是会有seq_len的问题

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有其他模型需要使用的话这里也可以保留

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果有其他模型需要使用的话这里也可以保留

BOWEncoder只使用了Embedding,感觉由用户自己搭建比较好,不放在text.py中了

res = fluid.layers.concat(res, axis=1)
return res

class SimGRUEncoder(Layer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,text.py中已有GRU的接口可以直接使用,对外统一提供一个吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,text.py中已有GRU的接口可以直接使用,对外统一提供一个吧

好的

gru = fluid.layers.tanh(gru)
return gru

class SimLSTMEncoder(Layer):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以Sim去掉,另外可以参考text.py中已有的GRUEncoder接口提供类似的实现

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以Sim去掉,另外可以参考text.py中已有的GRUEncoder接口提供类似的实现

好的

self.emb_dim = emb_dim
self.lstm_dim = lstm_dim
self.hidden_dim = hidden_dim
self.seq_len = seq_len
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还请注意下seq_len的问题

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还请注意下seq_len的问题

好的。

@guoshengCS
Copy link
Collaborator

另外还请在新增API时加上文档

@jinyuKING
Copy link
Author

另外还请在新增API时加上文档

已添加

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有name这个参数


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`` .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里感觉不要说如何实现,用了Conv2D和Pool2D。而是描述做了什么,做了Conv1D和Pool1D

Variable
Example:
```python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请参考其他添加示例代码的方法 https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/dygraph/nn.py#L143

另外,尽量保证行长度不超过80


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`` .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没有包含Embedding

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要描述清楚这个接口做了什么,按照这里的描述无法区分这个CNNEncoder是做了多层CNN的堆叠还是多个CNN的并行

Return:
3-D Tensor, the result of input after embedding and conv1dPoollayer
Return Type:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class文档注释可以不用添加return内容

use_cudnn=self.use_cudnn
) for i in range(layer_num)])

def forward(self, input):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为class的method添加文档,说明输入参数和返回内容,上面那个Conv1DPoolLayer类似

@guoshengCS
Copy link
Collaborator

另外,请使用pre-commit

@guoshengCS
Copy link
Collaborator

后续可以加入stack的CNNEncoder,以及支持param_attr传入

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants