Exemple #1
0
    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()
Exemple #2
0
    def __init__(self,
                 concentration=None,
                 rate=None,
                 seed=None,
                 dtype=mstype.float32,
                 name="Gamma"):
        """
        Constructor of Gamma.
        """
        param = dict(locals())
        param['param_dict'] = {'concentration': concentration, 'rate': rate}
        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(concentration, (int, float)):
            raise TypeError("Input concentration can't be scalar")
        if isinstance(rate, (int, float)):
            raise TypeError("Input rate can't be scalar")

        super(Gamma, self).__init__(seed, dtype, name, param)

        self._concentration = self._add_parameter(concentration,
                                                  'concentration')
        self._rate = self._add_parameter(rate, 'rate')
        if self._concentration is not None:
            check_greater_zero(self._concentration, "concentration")
        if self._rate is not None:
            check_greater_zero(self._rate, "rate")

        # ops needed for the class
        self.log = log_generic
        self.square = P.Square()
        self.sqrt = P.Sqrt()
        self.squeeze = P.Squeeze(0)
        self.cast = P.Cast()
        self.dtypeop = P.DType()
        self.fill = P.Fill()
        self.shape = P.Shape()
        self.select = P.Select()
        self.greater = P.Greater()
        self.lgamma = nn.LGamma()
        self.digamma = nn.DiGamma()
        self.igamma = nn.IGamma()
Exemple #3
0
     'skip': ['backward']}),
 ('ReduceLogSumExp', {
     'block': nn.ReduceLogSumExp((0,), False),
     'desc_inputs': [Tensor(np.array([3, 4, 5, 6]).astype(np.float32))],
     'skip': ['backward']}),
 ('LGamma', {
     'block': nn.LGamma(),
     'desc_inputs': [Tensor(np.array([3, 4, 5, 6]).astype(np.float32))],
     'skip': ['backward']}),
 ('IGamma', {
     'block': nn.IGamma(),
     'desc_inputs': [Tensor(np.array([3, 4, 5, 6]).astype(np.float32)),
                     Tensor(np.array([3, 4, 5, 6]).astype(np.float32))],
     'skip': ['backward']}),
 ('DiGamma', {
     'block': nn.DiGamma(),
     'desc_inputs': [Tensor(np.array([3, 4, 5, 6]).astype(np.float32))],
     'skip': ['backward']}),
 ('LBeta', {
     'block': nn.LBeta(),
     'desc_inputs': [Tensor(np.array([3, 4, 5, 6]).astype(np.float32)),
                     Tensor(np.array([3, 4, 5, 6]).astype(np.float32))],
     'skip': ['backward']}),
 ('FlattenNet', {
     'block': FlattenNet(),
     'desc_inputs': [Tensor(np.ones([1, 2, 3, 4], np.float32))],
 }),
 ('PReLUNet', {
     'block': PReLUNet(),
     'desc_inputs': [Tensor(np.ones([1, 3, 4, 4], np.float32))],
 }),