提交 ca988e9e 编写于 作者: S simson

fix the condition when activation name is 0

上级 17c3148f
......@@ -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]()
......@@ -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,
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册