import tensorflow as tf

    def GetWordPred(o_):
      logits = tf.nn.xw_plus_b(o_, pred_mat, pred_bias)
      return tf.nn.softmax(logits)

    preds = GetWordPred(wvsum)
    z = tf.tile(tf.reshape(tf.reduce_sum(preds,1),[-1,1]), [1, out_vocab_size])
    self.preds, self.z = preds, z
    self.probs = tf.div(preds, z) #normalize
    self.unweighted_xent = _SafeXEnt(self.y, self.probs)

    self._xent = _SafeXEnt(self.y, self.probs, class_weights=weights)

    self.cost = tf.reduce_mean(self.example_weights * self._xent)

