def __init__(self): super(DiGamma, self).__init__() # const numbers self.k_lanczos_gamma = 7 self.k_base_lanczos_coeff = 0.99999999999980993227684700473478 self.k_lanczos_coefficients = [676.520368121885098567009190444019, -1259.13921672240287047156078755283, 771.3234287776530788486528258894, -176.61502916214059906584551354, 12.507343278686904814458936853, -0.13857109526572011689554707, 9.984369578019570859563e-6, 1.50563273514931155834e-7] self.nan = np.nan self.pi = np.pi self.lanczos_gamma_plus_one_half = self.k_lanczos_gamma + 0.5 self.log_lanczos_gamma_plus_one_half = np.log(self.lanczos_gamma_plus_one_half) # operations self.log1p = P.Log1p() self.abs = P.Abs() self.shape = P.Shape() self.dtype = P.DType() self.fill = P.Fill() self.floor = P.Floor() self.equal = P.Equal() self.less = P.Less() self.select = P.Select() self.sin = P.Sin() self.cos = P.Cos() self.logicaland = P.LogicalAnd()
def __init__(self, concentration1=None, concentration0=None, seed=None, dtype=mstype.float32, name="Beta"): """ Constructor of Beta. """ param = dict(locals()) param['param_dict'] = { 'concentration1': concentration1, 'concentration0': concentration0 } valid_dtype = mstype.float_type Validator.check_type_name("dtype", dtype, valid_dtype, type(self).__name__) # As some operators can't accept scalar input, check the type here if isinstance(concentration0, float): raise TypeError("Input concentration0 can't be scalar") if isinstance(concentration1, float): raise TypeError("Input concentration1 can't be scalar") super(Beta, self).__init__(seed, dtype, name, param) self._concentration1 = self._add_parameter(concentration1, 'concentration1') self._concentration0 = self._add_parameter(concentration0, 'concentration0') if self._concentration1 is not None: check_greater_zero(self._concentration1, "concentration1") if self._concentration0 is not None: check_greater_zero(self._concentration0, "concentration0") # ops needed for the class self.log = log_generic self.log1p = P.Log1p() self.neg = P.Neg() self.pow = P.Pow() self.squeeze = P.Squeeze(0) self.cast = P.Cast() self.fill = P.Fill() self.shape = P.Shape() self.select = P.Select() self.logicaland = P.LogicalAnd() self.greater = P.Greater() self.digamma = nn.DiGamma() self.lbeta = nn.LBeta()
def __init__(self, power=0., name='PowerTransform'): param = dict(locals()) param['param_dict'] = {'power': power} super(PowerTransform, self).__init__(name=name, param=param) self._power = self._add_parameter(power, 'power') check_greater_equal_zero(self._power, 'Power') self.pow = P.Pow() self.dtypeop = P.DType() self.cast = P.Cast() self.exp = exp_generic self.expm1 = P.Expm1() self.log = log_generic self.log1p = P.Log1p()
def __init__(self, loc=None, scale=None, seed=None, dtype=mstype.float32, name="Logistic"): """ Constructor of Logistic. """ param = dict(locals()) param['param_dict'] = {'loc': loc, 'scale': scale} valid_dtype = mstype.float_type Validator.check_type_name("dtype", dtype, valid_dtype, type(self).__name__) super(Logistic, self).__init__(seed, dtype, name, param) self._loc = self._add_parameter(loc, 'loc') self._scale = self._add_parameter(scale, 'scale') if self._scale is not None: check_greater_zero(self._scale, "scale") # ops needed for the class self.cast = P.Cast() self.const = P.ScalarToArray() self.consttensor = P.ScalarToTensor() self.dtypeop = P.DType() self.exp = exp_generic self.expm1 = P.Expm1() self.fill = P.Fill() self.less = P.Less() self.log = log_generic self.log1p = P.Log1p() self.logicalor = P.LogicalOr() self.erf = P.Erf() self.greater = P.Greater() self.sigmoid = P.Sigmoid() self.squeeze = P.Squeeze(0) self.select = P.Select() self.shape = P.Shape() self.softplus = self._softplus self.sqrt = P.Sqrt() self.uniform = C.uniform self.threshold = np.log(np.finfo(np.float32).eps) + 1. self.tiny = np.finfo(np.float).tiny self.sd_const = np.pi / np.sqrt(3)
def __init__(self): super(LBeta, self).__init__() # const numbers self.log_2pi = np.log(2 * np.pi) self.minimax_coeff = [-0.165322962780713e-02, 0.837308034031215e-03, -0.595202931351870e-03, 0.793650666825390e-03, -0.277777777760991e-02, 0.833333333333333e-01] # operations self.log = P.Log() self.log1p = P.Log1p() self.less = P.Less() self.select = P.Select() self.shape = P.Shape() self.dtype = P.DType() self.lgamma = LGamma()
def __init__(self): super(Log1pNet, self).__init__() self.log1p = P.Log1p()
def __init__(self): super().__init__() # self.softplus = P.Softplus() self.log1p = P.Log1p() self.exp = P.Exp()
def __init__(self, strategy1, strategy2): super().__init__() self.matmul = P.MatMul().set_strategy(strategy1) self.log1p = P.Log1p().set_strategy(strategy2) self.matmul2 = P.MatMul().set_strategy(strategy1)
def __init__(self): super(NetLog1p, self).__init__() self.log1p = P.Log1p()