示例#1
0
    def __init__(self, y, weights=None):
        self._y = check_array_type(y)
        self._numObv = len(self._y)

        if weights is None:
            self._numVar = 0
            self._w = np.ones(self._y.shape)
        else:
            self._w = check_array_type(weights)

        if len(self._w.shape) > 1:
            if self._w.shape[1] == 1:
                self._w = self._w.flatten()

        assert self._y.shape == self._w.shape, \
            "Input weight not of the same size as y"

        self.loss(self._y)
示例#2
0
    def __init__(self, y, weights=None):
        self._y = check_array_type(y)
        self._numObv = len(self._y)

        if weights is None:
            self._numVar = 0
            self._w = np.ones(self._y.shape)
        else:
            self._w = check_array_type(weights)

        if len(self._w.shape) > 1:
            if self._w.shape[1] == 1:
                self._w = self._w.flatten()

        assert self._y.shape == self._w.shape, \
            "Input weight not of the same size as y"

        self.loss(self._y)
示例#3
0
文件: ode_loss.py 项目: etyephe/pygom
 def __init__(self, theta, ode, x0, t0, t, y, state_name,
              sigma=None, target_param=None, target_state=None):
     if sigma is None:
         super(NormalLoss, self).__init__(theta, ode, x0, t0, t, y,
                                          state_name, sigma,
                                          target_param, target_state)
     else:
         sigma = check_array_type(sigma)
         super(NormalLoss, self).__init__(theta, ode, x0, t0, t, y,
                                          state_name, 1.0/sigma,
                                          target_param, target_state)
示例#4
0
 def __init__(self,
              theta,
              ode,
              x0,
              t0,
              t,
              y,
              state_name,
              sigma=None,
              target_param=None,
              target_state=None):
     if sigma is None:
         super(NormalLoss,
               self).__init__(theta, ode, x0, t0, t, y, state_name, sigma,
                              target_param, target_state)
     else:
         sigma = check_array_type(sigma)
         super(NormalLoss,
               self).__init__(theta, ode, x0, t0, t, y, state_name,
                              1.0 / sigma, target_param, target_state)
示例#5
0
    def __init__(self, y, sigma=1.0):
        err_str = "Standard deviation not of the correct "
        self._y = check_array_type(y)
        if isinstance(sigma, np.ndarray):
            if len(sigma.shape) > 1:
                if 1 in sigma.shape:
                    sigma = sigma.flatten()

                if y.shape == sigma.shape:
                    self._sigma = sigma
                else:
                    raise InitializeError(err_str + "size")
            else:
                if y.shape == sigma.shape:
                    self._sigma = sigma
                else:
                    raise InitializeError(err_str + "size")
        elif sigma is None or sigma == 1.0:
            self._sigma = np.ones(self._y.shape)
        else:
            raise InitializeError(err_str + "type")

        self._sigma2 = self._sigma**2
        self.loss(self._y)
示例#6
0
    def __init__(self, y, sigma=1.0):
        err_str = "Standard deviation not of the correct "
        self._y = check_array_type(y)
        if isinstance(sigma, np.ndarray):
            if len(sigma.shape) > 1:
                if 1 in sigma.shape:
                    sigma = sigma.flatten()

                if y.shape == sigma.shape:
                    self._sigma = sigma
                else:
                    raise InitializeError(err_str + "size")
            else:
                if y.shape == sigma.shape:
                    self._sigma = sigma
                else:
                    raise InitializeError(err_str + "size")
        elif sigma is None or sigma == 1.0:
            self._sigma = np.ones(self._y.shape)
        else:
            raise InitializeError(err_str + "type")

        self._sigma2 = self._sigma**2
        self.loss(self._y)
示例#7
0
 def __init__(self, y):
     self._y = check_array_type(y)
     self.loss(self._y)
示例#8
0
 def __init__(self, y):
     self._y = check_array_type(y)
     self.loss(self._y)