Skip to content

Commit

Permalink
Merge pull request #44 from notogawa/support_clipped_relu
Browse files Browse the repository at this point in the history
support ClippedReLU
  • Loading branch information
mitmul committed Nov 15, 2018
2 parents 06af407 + 5ecdf97 commit bfcc5c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions onnx_chainer/functions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from onnx_chainer.functions.activation import convert_ClippedReLU # NOQA
from onnx_chainer.functions.activation import convert_ELU # NOQA
from onnx_chainer.functions.activation import convert_HardSigmoid # NOQA
from onnx_chainer.functions.activation import convert_LeakyReLU # NOQA
Expand Down
14 changes: 14 additions & 0 deletions onnx_chainer/functions/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
from onnx_chainer import mapping


def convert_ClippedReLU(func, onnx_op_name, opset_version, input_names, output_names, parameters):
if opset_version == 1:
return helper.make_node(
onnx_op_name, input_names, output_names,
min=0.0, max=func.cap,
consumed_inputs=[1]
),
elif opset_version == 6:
return helper.make_node(
onnx_op_name, input_names, output_names,
min=0.0, max=func.cap,
),


def convert_ELU(func, onnx_op_name, opset_version, input_names, output_names, parameters):
if opset_version == 1:
return helper.make_node(
Expand Down
1 change: 1 addition & 0 deletions onnx_chainer/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Chainer Function -> (ONNX Operator, Operator set IDs)
operators = {
# Activation
'ClippedReLU': ('Clip', (1, 6)),
'ELU': ('Elu', (1, 6)),
'HardSigmoid': ('HardSigmoid', (1, 6)),
'LeakyReLU': ('LeakyRelu', (1, 6)),
Expand Down
1 change: 1 addition & 0 deletions tests/functions_tests/test_activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


@testing.parameterize(
{'name': 'clipped_relu'},
{'name': 'elu'},
{'name': 'hard_sigmoid'},
{'name': 'leaky_relu'},
Expand Down

0 comments on commit bfcc5c9

Please sign in to comment.