Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete unittest for trainer_config_helpers. #108

Merged
merged 3 commits into from
Sep 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions python/paddle/trainer/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ def create_input_parameter(
size,
dims=None,
sparse = None,
format = "csr"):
format = None):
if dims is None:
# TODO(yuyang18): print warning and callstack here!
dims = list()
Expand Down Expand Up @@ -2074,7 +2074,7 @@ def __init__(
active_type='linear',
device=None,
bias=False,
output_max_index=False):
output_max_index=None):
super(MaxLayer, self).__init__(name, 'max', 0, inputs=inputs, device=device)
config_assert(len(self.inputs) == 1, 'MaxLayer must have 1 input')
self.config.trans_type = trans_type
Expand All @@ -2083,7 +2083,8 @@ def __init__(
input_layer = self.get_input_layer(input_index)
self.set_layer_size(input_layer.size)
self.create_bias_parameter(bias, self.config.size)
self.config.output_max_index=output_max_index
if output_max_index is not None:
self.config.output_max_index = output_max_index


@config_layer('maxid')
Expand Down Expand Up @@ -2440,7 +2441,7 @@ def __init__(
inputs,
size=0,
bias=True,
error_clipping_threshold=0.0,
error_clipping_threshold=None,
**xargs):
config_assert(inputs, 'inputs cannot be empty')
super(MixedLayer, self).__init__(
Expand Down Expand Up @@ -2510,7 +2511,8 @@ def __init__(

self.create_bias_parameter(bias, self.config.size)

self.config.error_clipping_threshold = error_clipping_threshold
if error_clipping_threshold is not None:
self.config.error_clipping_threshold = error_clipping_threshold

# like MixedLayer, but no bias parameter
@config_func
Expand Down
9 changes: 7 additions & 2 deletions python/paddle/trainer_config_helpers/activations.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
__all__ = ["TanhActivation", "SigmoidActivation",
"SoftmaxActivation", "IdentityActivation", "LinearActivation",
'SequenceSoftmaxActivation', 'ExpActivation',
"ReluActivation", "BReluActivation", "SoftReluActivation", "STanhActivation",
"AbsActivation", "SquareActivation", "BaseActivation"]
"ReluActivation", "BReluActivation", "SoftReluActivation",
"STanhActivation",
"AbsActivation", "SquareActivation",
"BaseActivation"]


class BaseActivation(object):
Expand All @@ -36,6 +38,9 @@ def __init__(self, name, support_hppl):
self.name = name
self.support_hppl = support_hppl

def __repr__(self):
return self.name


class TanhActivation(BaseActivation):
"""
Expand Down
Loading