From: @yelihua Reviewed-by: @lilongfei15,@wenkai_dist,@lilongfei15 Signed-off-by: @lilongfei15tags/v1.1.0
| @@ -107,9 +107,9 @@ class ParamTypeEnum(Enum): | |||||
| class ActivationFuncEnum(Enum): | class ActivationFuncEnum(Enum): | ||||
| """Activation functions.""" | """Activation functions.""" | ||||
| TANH = 'Tanh' | |||||
| SIGMOID = 'Sigmoid' | |||||
| RELU = 'ReLU' | |||||
| TANH = 'tanh' | |||||
| SIGMOID = 'sigmoid' | |||||
| RELU = 'relu' | |||||
| class ConditionContext: | class ConditionContext: | ||||
| @@ -19,20 +19,21 @@ from mindinsight.datavisual.data_transform.graph import NodeTypeEnum | |||||
| from mindinsight.debugger.common.exceptions.exceptions import DebuggerParamValueError | from mindinsight.debugger.common.exceptions.exceptions import DebuggerParamValueError | ||||
| _ACTIVATIONS = [ | _ACTIVATIONS = [ | ||||
| 'ELU', | |||||
| 'FastGelu', | |||||
| 'GELU', | |||||
| 'HSigmoid', | |||||
| 'HSwish', | |||||
| 'LeakyReLU', | |||||
| 'LogSigmoid', | |||||
| 'LogSoftmax', | |||||
| 'PReLU', | |||||
| 'ReLU', | |||||
| 'ReLU6', | |||||
| 'Sigmoid', | |||||
| 'Softmax', | |||||
| 'Tanh' | |||||
| 'elu', | |||||
| 'fastgelu', | |||||
| 'gelu', | |||||
| 'hsigmoid', | |||||
| 'hswish', | |||||
| 'leakyrelu', | |||||
| 'logsigmoid', | |||||
| 'logsoftmax', | |||||
| 'prelu', | |||||
| 'relu', | |||||
| 'relu6', | |||||
| 'reluv2', | |||||
| 'sigmoid', | |||||
| 'softmax', | |||||
| 'tanh' | |||||
| ] | ] | ||||
| @@ -122,7 +123,7 @@ def is_activation_node(node, condition=None): | |||||
| if not is_gradient_node(node): | if not is_gradient_node(node): | ||||
| node_type = node.type | node_type = node.type | ||||
| for activation_name in activation_funcs: | for activation_name in activation_funcs: | ||||
| if node_type == activation_name: | |||||
| if node_type.lower() == activation_name: | |||||
| return True | return True | ||||
| return False | return False | ||||
| @@ -1 +1,48 @@ | |||||
| {"nodes": [{"name": "Default", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]} | |||||
| { | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "Default", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "Default/network-WithLossCell", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| @@ -1 +1,104 @@ | |||||
| {"nodes": [{"name": "graph_0", "type": "name_scope", "nodes": [{"name": "graph_0/Default", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]}, {"name": "graph_1", "type": "name_scope", "nodes": [{"name": "graph_1/Default", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]}]} | |||||
| { | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0/Default", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| }, | |||||
| { | |||||
| "name": "graph_1", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_1/Default", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", | |||||
| "type": "name_scope", | |||||
| "nodes": [ | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89", | |||||
| "type": "ReLUV2", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| }, | |||||
| { | |||||
| "name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", | |||||
| "type": "ReLU", | |||||
| "nodes": [] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| } | |||||
| @@ -60,8 +60,8 @@ class TestNodeTypeIdentifier: | |||||
| ('Default/mock/relu_ReLU-op11', "ReLU", None, True), | ('Default/mock/relu_ReLU-op11', "ReLU", None, True), | ||||
| ('Gradients/mock/relu_ReLU-op11', "ReLU", None, False), | ('Gradients/mock/relu_ReLU-op11', "ReLU", None, False), | ||||
| ('Default/mock/relu_ReLU-op11', "Parameter", None, False), | ('Default/mock/relu_ReLU-op11', "Parameter", None, False), | ||||
| ('Default/mock/relu_ReLU-op11', "ReLU", {'activation_func': 'Softmax'}, False), | |||||
| ('Default/mock/relu_ReLU-op11', "Softmax", {'activation_func': ['ReLU', 'Softmax']}, True) | |||||
| ('Default/mock/relu_ReLU-op11', "ReLU", {'activation_func': 'softmax'}, False), | |||||
| ('Default/mock/relu_ReLU-op11', "Softmax", {'activation_func': ['relu', 'softmax']}, True) | |||||
| ]) | ]) | ||||
| def test_activate_node(self, name, node_type, condition, result): | def test_activate_node(self, name, node_type, condition, result): | ||||
| """Test activate node.""" | """Test activate node.""" | ||||
| @@ -73,7 +73,7 @@ class TestGraphHandler: | |||||
| @pytest.mark.parametrize("node_type, condition, result_file", [ | @pytest.mark.parametrize("node_type, condition, result_file", [ | ||||
| ("weight", None, "search_nodes_by_type_0.json"), | ("weight", None, "search_nodes_by_type_0.json"), | ||||
| ("activation", {'activation_func': ['ReLU', 'Softmax']}, "search_nodes_by_type_1.json") | |||||
| ("activation", {'activation_func': ['relu', 'softmax']}, "search_nodes_by_type_1.json") | |||||
| ]) | ]) | ||||
| def test_search_nodes_by_type(self, node_type, condition, result_file): | def test_search_nodes_by_type(self, node_type, condition, result_file): | ||||
| """Test search nodes by type.""" | """Test search nodes by type.""" | ||||