Esempio n. 1
0
    def __init__(self,
                 num_dimensions,
                 user_mat,
                 first_mat,
                 gparams,
                 variance_prior=None,
                 offset_prior=None,
                 active_dims=None):
        super(MyKernel, self).__init__(active_dims=active_dims)
        self.user_mat = user_mat
        self.first_mat = first_mat

        self.psi_dim_one = gparams.psi_indices[0]
        self.psi_dim_two = gparams.psi_indices[1]
        self.psi_indices = gparams.psi_indices
        #print(self.psi_dim_one)
        #print(self.psi_dim_two)

        self.init_u1 = gparams.sigma_u[0][0]
        #init_u1 = gparams.u1

        self.init_u2 = gparams.sigma_u[1][1]
        #init_u2 = gparams.u2

        #self.register_parameter(name="u1", parameter=torch.nn.Parameter(init_u1*torch.tensor(1.0)))
        self.register_parameter(name="raw_u1",
                                parameter=torch.nn.Parameter(
                                    self.init_u1 * torch.tensor(1.0)))

        #self.register_parameter(name="u2", parameter=torch.nn.Parameter(init_u2*torch.tensor(1.0)))
        self.register_parameter(name="raw_u2",
                                parameter=torch.nn.Parameter(
                                    self.init_u2 * torch.tensor(1.0)))
        t = gparams.sigma_u[0][0]**.5 * gparams.sigma_u[1][1]**.5
        self.r = (gparams.sigma_u[0][1] + t) / t
        #r = gparams.rho_term
        #self.register_parameter(name="rho", parameter=torch.nn.Parameter(r*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho",
                                parameter=torch.nn.Parameter(
                                    self.r * torch.tensor(1.0)))

        #initial_value=init_u2*torch.tensor(1.0)
        #initial_value=init_u1*torch.tensor(1.0)
        self.register_constraint(
            "raw_u1",
            constraint=constraints.Positive(initial_value=self.init_u1 *
                                            torch.tensor(1.0)))
        #initial_value=init_u2*torch.tensor(1.0)
        self.register_constraint(
            "raw_u2",
            constraint=constraints.Positive(initial_value=self.init_u2 *
                                            torch.tensor(1.0)))

        self.register_constraint("raw_rho",
                                 constraint=constraints.Interval(0.0, 2.0))
 def __init__(self, num_dimensions,user_mat, first_mat,gparams, variance_prior=None, offset_prior=None, active_dims=None):
     super(MyKernel, self).__init__(active_dims=active_dims)
     self.user_mat = user_mat
     self.first_mat = first_mat
     self.action_indices = [8,13]
     self.psi_dim_one = gparams.psi_indices[0]
     self.psi_dim_two = gparams.psi_indices[1]
     self.psi_indices =gparams.psi_indices
     print(self.psi_indices)
     self.g_indices = [i for i in range(8)]
     self.action_indices_one = [i for i in range(8,8+5)]
     self.action_indices_two = [i for i in range(8+5,18)]
     self.init_u1 = gparams.sigma_u[0][0]
     
     
     self.init_u2 = gparams.sigma_u[1][1]
     
     
     
     self.register_parameter(name="raw_u1", parameter=torch.nn.Parameter(1.0*torch.tensor(1.0)))
     self.register_parameter(name="test", parameter=torch.nn.Parameter(1.0*torch.tensor(1.0)))
     
     
     self.register_parameter(name="raw_u2", parameter=torch.nn.Parameter(1.0*torch.tensor(1.0)))
     t =gparams.sigma_u[0][0]**.5 * gparams.sigma_u[1][1]**.5
     self.r = (gparams.sigma_u[0][1]+t)/t
     
     self.register_parameter(name="raw_rho", parameter=torch.nn.Parameter(1.0*torch.tensor(1.0)))
     
     
     self.register_constraint("raw_u1",constraint= constraints.Positive())
     
     self.register_constraint("raw_u2",constraint= constraints.Positive())
         
     self.register_constraint("raw_rho",constraint= constraints.Interval(0.0,2.0))
     self.u1 = self.init_u1
     self.u2 = self.init_u2
     self.rho = self.r
    def __init__(self,
                 num_dimensions,
                 user_mat,
                 first_mat,
                 gparams,
                 variance_prior=None,
                 offset_prior=None,
                 active_dims=None):
        super(MyKernel, self).__init__(active_dims=active_dims)
        self.user_mat = user_mat
        self.first_mat = first_mat

        self.psi_dim_one = gparams.psi_indices[0]
        self.psi_dim_two = gparams.psi_indices[1]
        self.psi_indices = gparams.psi_indices
        self.action_indices_one = gparams.action_indices_one
        self.action_indices_two = gparams.action_indices_two
        self.g_indices = gparams.g_indices
        #print(self.psi_dim_one)
        #print(self.psi_dim_two)

        #init_u1 = gparams.sigma_u[0][0]

        print(gparams.u1)
        print(gparams.u2)
        self.init_u1 = gparams.u1 * torch.tensor(1.0)

        #init_u2 = gparams.sigma_u[1][1]
        self.init_u2 = gparams.u2 * torch.tensor(1.0)
        self.init_u3 = gparams.u3 * torch.tensor(1.0)
        self.init_u4 = gparams.u4 * torch.tensor(1.0)

        self.r12 = gparams.r12 * torch.tensor(1.0)
        self.r13 = gparams.r13 * torch.tensor(1.0)
        self.r14 = gparams.r14 * torch.tensor(1.0)

        self.r23 = gparams.r23 * torch.tensor(1.0)
        self.r24 = gparams.r24 * torch.tensor(1.0)

        self.r34 = gparams.r34 * torch.tensor(1.0)

        #self.register_parameter(name="u1", parameter=torch.nn.Parameter(init_u1*torch.tensor(1.0)))
        self.register_parameter(name="raw_u1",
                                parameter=torch.nn.Parameter(
                                    self.init_u1 * torch.tensor(1.0)))

        #self.register_parameter(name="u2", parameter=torch.nn.Parameter(init_u2*torch.tensor(1.0)))
        self.register_parameter(name="raw_u2",
                                parameter=torch.nn.Parameter(
                                    self.init_u2 * torch.tensor(1.0)))

        #self.register_parameter(name="u3", parameter=torch.nn.Parameter(init_u3*torch.tensor(1.0)))
        self.register_parameter(name="raw_u3",
                                parameter=torch.nn.Parameter(
                                    self.init_u3 * torch.tensor(1.0)))

        #self.register_parameter(name="u4", parameter=torch.nn.Parameter(init_u4*torch.tensor(1.0)))
        self.register_parameter(name="raw_u4",
                                parameter=torch.nn.Parameter(
                                    self.init_u4 * torch.tensor(1.0)))

        #t =gparams.sigma_u[0][0]**.5 * gparams.sigma_u[1][1]**.5
        #r = (gparams.sigma_u[0][1]+t)/t
        #sr = gparams.rho_term
        #self.register_parameter(name="rho_12", parameter=torch.nn.Parameter(r12*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_12",
                                parameter=torch.nn.Parameter(
                                    self.r12 * torch.tensor(1.0)))

        #self.register_parameter(name="rho_13", parameter=torch.nn.Parameter(r13*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_13",
                                parameter=torch.nn.Parameter(
                                    self.r13 * torch.tensor(1.0)))

        #self.register_parameter(name="rho_14", parameter=torch.nn.Parameter(r14*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_14",
                                parameter=torch.nn.Parameter(
                                    self.r14 * torch.tensor(1.0)))

        #self.register_parameter(name="rho_23", parameter=torch.nn.Parameter(r23*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_23",
                                parameter=torch.nn.Parameter(
                                    self.r23 * torch.tensor(1.0)))

        #self.register_parameter(name="rho_24", parameter=torch.nn.Parameter(r24*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_24",
                                parameter=torch.nn.Parameter(
                                    self.r24 * torch.tensor(1.0)))

        #self.register_parameter(name="rho_34", parameter=torch.nn.Parameter(r34*torch.tensor(1.0)))
        self.register_parameter(name="raw_rho_34",
                                parameter=torch.nn.Parameter(
                                    self.r34 * torch.tensor(1.0)))

        self.register_constraint("raw_u1", constraint=constraints.Positive())
        self.register_constraint("raw_u2", constraint=constraints.Positive())
        self.register_constraint("raw_u3", constraint=constraints.Positive())
        self.register_constraint("raw_u4", constraint=constraints.Positive())

        self.register_constraint("raw_rho_12",
                                 constraint=constraints.Interval(0.0, 2.0))
        self.register_constraint("raw_rho_13",
                                 constraint=constraints.Interval(0.0, 2.0))
        self.register_constraint("raw_rho_14",
                                 constraint=constraints.Interval(0.0, 2.0))
        self.register_constraint("raw_rho_23",
                                 constraint=constraints.Interval(0.0, 2.0))
        self.register_constraint("raw_rho_24",
                                 constraint=constraints.Interval(0.0, 2.0))
        self.register_constraint("raw_rho_34",
                                 constraint=constraints.Interval(0.0, 2.0))
        #print('got here')

        self.u1 = gparams.u1
        #print('initialized')
        #init_u2 = gparams.sigma_u[1][1]
        self.u2 = gparams.u2
        #print('initialized')
        self.u3 = gparams.u3

        self.u4 = gparams.u4

        self.rho_12 = gparams.r12

        self.rho_13 = gparams.r13

        self.rho_14 = gparams.r14

        self.rho_23 = gparams.r23

        self.rho_24 = gparams.r24

        self.rho_34 = gparams.r34