提交 3b7d9f7b 编写于 作者: T tensor-tang

remove kwargs of some activation api

上级 f66d08c2
...@@ -257,23 +257,23 @@ paddle.fluid.layers.sum ArgSpec(args=[], varargs='args', keywords='kwargs', defa ...@@ -257,23 +257,23 @@ paddle.fluid.layers.sum ArgSpec(args=[], varargs='args', keywords='kwargs', defa
paddle.fluid.layers.slice ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.slice ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.shape ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.shape ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.maxout ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.maxout ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.sigmoid ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.sigmoid ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.logsigmoid ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.logsigmoid ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.exp ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.exp ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.tanh ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.tanh ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.tanh_shrink ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.tanh_shrink ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.softshrink ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.softshrink ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.sqrt ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.sqrt ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.abs ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.abs ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.ceil ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.ceil ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.floor ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.floor ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.cos ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.cos ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.sin ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.sin ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.round ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.round ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.reciprocal ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.reciprocal ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.square ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.square ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.softplus ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.softplus ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.softsign ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.softsign ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None)
paddle.fluid.layers.brelu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.brelu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.leaky_relu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.leaky_relu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
paddle.fluid.layers.soft_relu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None) paddle.fluid.layers.soft_relu ArgSpec(args=[], varargs='args', keywords='kwargs', defaults=None)
......
...@@ -23,7 +23,10 @@ from ..proto import framework_pb2 ...@@ -23,7 +23,10 @@ from ..proto import framework_pb2
from ..framework import OpProtoHolder, Variable from ..framework import OpProtoHolder, Variable
from ..layer_helper import LayerHelper from ..layer_helper import LayerHelper
__all__ = ['deprecated', 'generate_layer_fn', 'autodoc', 'templatedoc'] __all__ = [
'deprecated', 'generate_layer_fn', 'generate_layer_fn_noattr', 'autodoc',
'templatedoc'
]
def _convert_(name): def _convert_(name):
...@@ -205,6 +208,30 @@ def generate_layer_fn(op_type): ...@@ -205,6 +208,30 @@ def generate_layer_fn(op_type):
return func return func
def generate_layer_fn_noattr(op_type):
"""Register the Python layer for an Operator without Attribute.
Args:
op_type: The name of the operator to be created.
This function takes in the operator type (sigmoid, exp , tanh etc) and
creates the operator functionality.
"""
op_proto = OpProtoHolder.instance().get_op_proto(op_type)
def func(x):
helper = LayerHelper(op_type, **locals())
output = helper.create_tmp_variable(dtype=helper.input_dtype())
helper.append_op(
type=op_type, inputs={"X": [x]}, outputs={"Out": [output]})
return output
func.__name__ = op_type
func.__doc__ = _generate_doc_string_(op_proto)
return func
def deprecated(func_or_class): def deprecated(func_or_class):
""" """
Deprecated warning decorator. It will result a warning message. Deprecated warning decorator. It will result a warning message.
......
...@@ -13,15 +13,27 @@ ...@@ -13,15 +13,27 @@
# limitations under the License. # limitations under the License.
from __future__ import print_function from __future__ import print_function
from .layer_function_generator import generate_layer_fn from .layer_function_generator import generate_layer_fn, generate_layer_fn_noattr
__activations__ = [ __activations__ = [
'softshrink',
'brelu',
'leaky_relu',
'soft_relu',
'elu',
'relu6',
'pow',
'stanh',
'hard_sigmoid',
'swish',
]
__activations_noattr__ = [
'sigmoid', 'sigmoid',
'logsigmoid', 'logsigmoid',
'exp', 'exp',
'tanh', 'tanh',
'tanh_shrink', 'tanh_shrink',
'softshrink',
'sqrt', 'sqrt',
'abs', 'abs',
'ceil', 'ceil',
...@@ -33,15 +45,6 @@ __activations__ = [ ...@@ -33,15 +45,6 @@ __activations__ = [
'square', 'square',
'softplus', 'softplus',
'softsign', 'softsign',
'brelu',
'leaky_relu',
'soft_relu',
'elu',
'relu6',
'pow',
'stanh',
'hard_sigmoid',
'swish',
] ]
__all__ = [ __all__ = [
...@@ -75,6 +78,11 @@ __all__ = [ ...@@ -75,6 +78,11 @@ __all__ = [
for _OP in set(__all__): for _OP in set(__all__):
globals()[_OP] = generate_layer_fn(_OP) globals()[_OP] = generate_layer_fn(_OP)
__all__ += __activations_noattr__
for _OP in set(__activations_noattr__):
globals()[_OP] = generate_layer_fn_noattr(_OP)
__all__ += ["uniform_random"] __all__ += ["uniform_random"]
_uniform_random_ = generate_layer_fn('uniform_random') _uniform_random_ = generate_layer_fn('uniform_random')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册