Browse Source

!2199 Fix the condition when activation name is 0

Merge pull request !2199 from Simson/push-to-opensource
tags/v0.5.0-beta
mindspore-ci-bot Gitee 5 years ago
parent
commit
4e3b3711be
3 changed files with 3 additions and 7 deletions
  1. +2
    -2
      mindspore/nn/layer/activation.py
  2. +1
    -1
      tests/ut/python/nn/test_dense.py
  3. +0
    -4
      tests/ut/python/pynative_mode/nn/test_activation.py

+ 2
- 2
mindspore/nn/layer/activation.py 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]()

+ 1
- 1
tests/ut/python/nn/test_dense.py 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,


+ 0
- 4
tests/ut/python/pynative_mode/nn/test_activation.py 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)


Loading…
Cancel
Save