def _get_cost_function(self):
        """Compute the cost of the Mittens objective function.

        If self.mittens = 0, this is the same as the cost of GloVe.
        """
        self.weights = tf.placeholder(
            tf.float32, shape=[self.n_words, self.n_words])
        self.log_coincidence = tf.placeholder(
            tf.float32, shape=[self.n_words, self.n_words])
        self.diffs = tf.subtract(self.model, self.log_coincidence)
        cost = tf.reduce_sum(
            0.5 * tf.multiply(self.weights, tf.square(self.diffs)))
        if self.mittens > 0:
            self.mittens = tf.constant(self.mittens, tf.float32)
            cost += self.mittens * tf.reduce_sum(
                tf.multiply(
                    self.has_embedding,
                    self._tf_squared_euclidean(
                        tf.add(self.W, self.C),
                        self.original_embedding)))
        tf.summary.scalar("cost", cost)
        return cost
def _get_cost_function ( self ) : self . weights = tf . placeholder ( tf . float32 , shape = [ self . n_words , self . n_words ] ) self . log_coincidence = tf . placeholder ( tf . float32 , shape = [ self . n_words , self . n_words ] ) self . diffs = tf . subtract ( self . model , self . log_coincidence ) cost = tf . reduce_sum ( 0.5 * tf . multiply ( self . weights , tf . square ( self . diffs ) ) ) if self . mittens > 0 : self . mittens = tf . constant ( self . mittens , tf . float32 ) cost += self . mittens * tf . reduce_sum ( tf . multiply ( self . has_embedding , self . _tf_squared_euclidean ( tf . add ( self . W , self . C ) , self . original_embedding ) ) ) tf . summary . scalar ( "cost" , cost ) return cost
Compute the cost of the Mittens objective function.

        If self.mittens = 0, this is the same as the cost of GloVe.