def __init__(self, net, sens=False): super().__init__() self.grad = P.GradOperation(get_all=True, get_by_list=True, sens_param=sens) self.net = net self.params = ParameterTuple(self.net.trainable_params())
def __init__(self, grad, network, wrt_params=False, real_inputs_count=None): super().__init__() self.network = network self.grad = grad self.sens_param = self.grad.sens_param self.wrt_params = wrt_params self.real_inputs_count = real_inputs_count if self.wrt_params: self.params = ParameterTuple(self.network.trainable_params())
def __init__(self, func, wrt_params, params, grad_op, sens): super(Bprop, self).__init__(auto_prefix=False) self.func = func self.wrt_params = wrt_params self.params = None if self.wrt_params and params: self.params = ParameterTuple(params) self.grad = grad_op self.sens = sens self.with_sens = False if sens is not None: self.with_sens = True
def __init__(self, network): super(GetParamGrad, self).__init__(auto_prefix=False) self.network = network self.weights = ParameterTuple(network.trainable_params()) self.grad = C.GradOperation(get_by_list=True, sens_param=True)