msg="The function 'replace_sub()' is deprecated, please use 'upgrade_sublayer()' instead."
stop_layer_name)
logger.error(DeprecationWarning(msg))
returnafter_stop
raiseDeprecationWarning(msg)
defupdate_res(self,return_patterns):
defupgrade_sublayer(self,
forreturn_patterninreturn_patterns:
layer_name_pattern:Union[str,List[str]],
pattern_list=return_pattern.split(".")
handle_func:Callable[[nn.Layer,str],nn.Layer]
ifnotpattern_list:
)->Dict[str,nn.Layer]:
continue
"""use 'handle_func' to modify the sub-layer(s) specified by 'layer_name_pattern'.
sub_layer_parent=self
whilelen(pattern_list)>1:
Args:
if'['inpattern_list[0]:
layer_name_pattern (Union[str, List[str]]): The name of layer to be modified by 'handle_func'.
sub_layer_name=pattern_list[0].split('[')[0]
handle_func (Callable[[nn.Layer, str], nn.Layer]): The function to modify target layer specified by 'layer_name_pattern'. The formal params are the layer(nn.Layer) and pattern(str) that is (a member of) layer_name_pattern (when layer_name_pattern is List type). And the return is the layer processed.