MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / clone_state

Method clone_state

codegeex/mindspore/src/utils.py:59–73  ·  view source on GitHub ↗

r""" parameter_tuple: ParameterTuple. The parameters of the network prefix: str. The prefix name of the parameters init: str. The initialization method

(self, parameter_tuple, prefix, init)

Source from the content-addressed store, hash-verified

57 self.moments2 = self.clone_state(self.parameters, prefix='adam_v', init='zeros')
58
59 def clone_state(self, parameter_tuple, prefix, init):
60 r"""
61 parameter_tuple: ParameterTuple. The parameters of the network
62 prefix: str. The prefix name of the parameters
63 init: str. The initialization method
64 """
65 new = []
66 for old_param in parameter_tuple:
67 new_state = Parameter(initializer(init, shape=old_param.shape, dtype=mstype.float32))
68 new_state.param_info = old_param.param_info.clone()
69 new_state.is_init = False
70 new_state.set_data(initializer(init, shape=old_param.shape, dtype=mstype.float32))
71 new_state.name = prefix + '.' + new_state.name
72 new.append(new_state)
73 return ParameterTuple(new)
74
75
76get_square_sum = C.MultitypeFuncGraph("get_square_sum")

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected