Пример #1
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         # loss for L(Theta)
         UI_u, IU_i, IL_i, LI_l, predict_vector = self._create_inference(
             self.item_input)
         if self.ispairwise.lower() == "true":
             self.output = tf.reduce_sum(predict_vector, 1)
             _, IU_j, IL_j, _, predict_vector_neg = self._create_inference(
                 self.item_input_neg)
             output_neg = tf.reduce_sum(predict_vector_neg, 1)
             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))) + \
                         self.reg_w * (tf.reduce_sum(tf.square(self.W)) + tf.reduce_sum(tf.square(self.h)))
         else:
             prediction = tf.layers.dense(inputs=predict_vector,
                                          units=1,
                                          activation=tf.nn.sigmoid)
             self.output = tf.squeeze(prediction)
             self.loss = learner.pointwise_loss(
                 self.loss_function, self.labels,
                 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)))
Пример #2
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         p1, q1, r1, predict_vector = self._create_inference(
             self.item_input)
         if self.ispairwise.lower() == "true":
             self.output = tf.reduce_sum(predict_vector, 1)
             _, q2, _, predict_vector_neg = self._create_inference(
                 self.item_input_neg)
             output_neg = tf.reduce_sum(predict_vector_neg, 1)
             self.result = self.output - output_neg
             self.loss = learner.pairwise_loss(
                 self.loss_function, self.result) + self.reg_mf * (
                     tf.reduce_sum(tf.square(p1)) + tf.reduce_sum(
                         tf.square(r1)) + tf.reduce_sum(tf.square(q2)) +
                     tf.reduce_sum(tf.square(q1)))
         else:
             prediction = tf.layers.dense(inputs=predict_vector,
                                          units=1,
                                          activation=tf.nn.sigmoid)
             self.output = tf.squeeze(prediction)
             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)))
Пример #3
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         p1,q1,r1,predict_vector = self._create_inference()
         prediction = tf.layers.dense(inputs=predict_vector,units=1, activation=tf.nn.sigmoid)
         self.output = tf.squeeze(prediction)
         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)))
Пример #4
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
Пример #5
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         UI_u, IU_i, LI_l, predict_vector = self._create_inference()
         prediction = tf.layers.dense(inputs=predict_vector,
                                      units=1,
                                      activation=tf.nn.sigmoid)
         self.output = tf.squeeze(prediction)
         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)))
Пример #6
0
 def _create_loss(self):
     with tf.name_scope("loss"):  
         p1, q1, self.output = self._create_inference(self.item_input)
         if self.is_pairwise is 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_mlp * l2_loss(p1, q2, q1)
         else:
             self.loss = learner.pointwise_loss(self.loss_function, self.labels, self.output) + \
                         self.reg_mlp * l2_loss(p1, q1)
Пример #7
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         p1,q1,r1,self.output = self._create_inference(self.item_input)
         if self.ispairwise.lower() =="true":
             _, q2,_,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(p1)) \
             +tf.reduce_sum(tf.square(r1)) + 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_mf * (tf.reduce_sum(tf.square(p1)) \
             +tf.reduce_sum(tf.square(r1))+ tf.reduce_sum(tf.square(q1)))
Пример #8
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.is_pairwise is 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 * l2_loss(p1) + \
                         self.gamma_bilinear * l2_loss(q2, q1)
         
         else:
             self.loss = learner.pointwise_loss(self.loss_function, self.labels, self.output) + \
                         self.lambda_bilinear * l2_loss(p1) + \
                         self.gamma_bilinear * l2_loss(q1)
Пример #9
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         # loss for L(Theta)
         p1, r1, q1, b1, self.output = self._create_inference(
             self.item_input)
         if self.is_pairwise is True:
             _, _, q2, b2, 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 * l2_loss(p1, r1, q2, q1, b1, b2, self.global_embedding)
         else:
             self.loss = learner.pointwise_loss(self.loss_function, self.labels, self.output) + \
                         self.reg_mf * l2_loss(p1, r1, q1, b1, self.global_embedding)
Пример #10
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         UI_u, IU_i, IL_i, LI_l, self.output = self._create_inference(
             self.item_input)
         if self.is_pairwise is 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 * l2_loss(UI_u, IU_i, IL_i, LI_l, IU_j, IL_j) + \
                         self.reg_w * l2_loss(self.W, self.h)
         else:
             self.loss = learner.pointwise_loss(self.loss_function, self.labels, self.output) + \
                         self.reg_mf * l2_loss(UI_u, IU_i, IL_i, LI_l)
Пример #11
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.lower() == "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)))
Пример #12
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.lower() == "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,tf.sigmoid(self.output)) + self.lambda_bilinear *\
                (tf.reduce_sum(tf.square(p1)))+self.gamma_bilinear *(tf.reduce_sum(tf.square(q1)))
Пример #13
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)))
Пример #14
0
#!/usr/local/bin/python
Пример #15
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.labels, self.output) + \
                     self.reg * l2_loss(UI_u, IU_i, LI_l)
Пример #16
0
 def _create_loss(self):
     with tf.name_scope("loss"):
         self.loss = learner.pointwise_loss(self.loss_function, self.labels,
                                            self.output)
Пример #17
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)))
Пример #18
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.labels, self.output) + \
                     self.reg_mf * l2_loss(p1, r1, q1)