fix the condition when activation name is 0

This commit is contained in:
simson 2020-06-17 11:10:15 +08:00
parent 17c3148ff8
commit ca988e9e69
3 changed files with 3 additions and 7 deletions

View File

@ -549,9 +549,9 @@ def get_activation(name):
Examples:
>>> sigmoid = nn.get_activation('sigmoid')
"""
if not name:
if name is None:
return None
if name not in _activation:
raise KeyError("Unknown activation type")
raise KeyError(f"Unknown activation type '{name}'")
return _activation[name]()

View File

@ -76,7 +76,7 @@ class Net(nn.Cell):
weight='normal',
bias='zeros',
has_bias=True,
activation=''):
activation=None):
super(Net, self).__init__()
self.dense = nn.Dense(input_channels,
output_channels,

View File

@ -46,10 +46,6 @@ def test_activation_param():
assert isinstance(output_np[0][0][0][0], (np.float32, np.float64))
def test_activation_empty():
assert nn.get_activation('') is None
# test softmax
def test_softmax_axis():
layer = nn.Softmax(1)