Beispiel #1
0
    def _create_loss(self):
        with tf.name_scope("loss"):

            self.loss = learner.pointwise_loss(self.loss_function, self.input_R, self.output)

            self.reg_loss = self.reg*(tf.nn.l2_loss(self.weights['encoder'])+tf.nn.l2_loss(self.weights['decoder'])+
                tf.nn.l2_loss(self.biases['encoder'])+tf.nn.l2_loss(self.biases['decoder']))
            self.loss = self.loss + self.reg_loss
Beispiel #2
0
    def _create_loss(self):
        with tf.name_scope("loss"):
            p1, q1, self.output = self._create_inference(self.item_input)
            if self.ispairwise == True:
                _, q2, self.output_neg = self._create_inference(
                    self.item_input_neg)
                result = self.output - self.output_neg
                self.loss = learner.pairwise_loss(self.loss_function,result) + self.reg_mf * ( tf.reduce_sum(tf.square(p1)) \
                + tf.reduce_sum(tf.square(q2)) + tf.reduce_sum(tf.square(q1)))

            else:
                self.loss = learner.pointwise_loss(self.loss_function, self.lables,self.output)+self.reg_mlp * (tf.reduce_sum(tf.square(p1)) \
                   + tf.reduce_sum(tf.square(q1)))
Beispiel #3
0
    def _create_loss(self):
        with tf.name_scope("loss"):
            p1, q1, self.output = self._create_inference(
                self.user_input, self.item_input, self.num_idx)
            if self.ispairwise == True:
                _, q2, output_neg = self._create_inference(
                    self.user_input_neg, self.item_input_neg, self.num_idx_neg)
                self.result = self.output - output_neg
                self.loss = learner.pairwise_loss(self.loss_function,self.result) + self.lambda_bilinear * ( tf.reduce_sum(tf.square(p1))) \
                +self.gamma_bilinear*(tf.reduce_sum(tf.square(q2)) + tf.reduce_sum(tf.square(q1)))

            else:
                self.loss = learner.pointwise_loss(self.loss_function, \
                self.lables,self.output) + self.lambda_bilinear *\
                (tf.reduce_sum(tf.square(p1)))+self.gamma_bilinear *(tf.reduce_sum(tf.square(q1)))
Beispiel #4
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         UI_u, IU_i, IL_i, LI_l, self.output = self._create_inference(
             self.item_input)
         if self.ispairwise == True:
             _, IU_j, IL_j, _, output_neg = self._create_inference(
                 self.item_input_neg)
             self.result = self.output - output_neg
             self.loss = learner.pairwise_loss(self.loss_function,self.result) + self.reg_mf * ( tf.reduce_sum(tf.square(UI_u)) \
             + tf.reduce_sum(tf.square(IU_i)) + tf.reduce_sum(tf.square(IL_i)) + tf.reduce_sum(tf.square(LI_l))+ \
              tf.reduce_sum(tf.square(LI_l))+tf.reduce_sum(tf.square(IU_j))+tf.reduce_sum(tf.square(IL_j)))
         else:
             self.loss = learner.pointwise_loss(self.loss_function,self.lables,self.output) + self.reg_mf * (tf.reduce_sum(tf.square(UI_u)) \
             +tf.reduce_sum(tf.square(IU_i))+ tf.reduce_sum(tf.square(IL_i))+tf.reduce_sum(tf.square(LI_l)))
Beispiel #5
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         UI_u, IU_i, LI_l, self.output = self._create_inference()
         self.loss = learner.pointwise_loss(self.loss_function,self.lables,self.output) + self.reg* (tf.reduce_sum(tf.square(UI_u)) \
         +tf.reduce_sum(tf.square(IU_i))+tf.reduce_sum(tf.square(LI_l)))
Beispiel #6
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         self.loss = learner.pointwise_loss(self.loss_function, self.lables,
                                            self.output)
Beispiel #7
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         p1,q1,r1,self.output = self._create_inference()
         self.loss = learner.pointwise_loss(self.loss_function,self.lables,self.output) + self.reg_mf * (tf.reduce_sum(tf.square(p1)) \
         +tf.reduce_sum(tf.square(r1))+ tf.reduce_sum(tf.square(q1)))