Пример #1
0
    def predict_on_batch(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch)
        decode_output = sess.run(util.tuple_to_list(*self.decode),
                                 feed_dict=feed)

        pred = get_answer_from_span(decode_output[1])
        return pred
Пример #2
0
 def predict_on_batch(self, sess, data_batch):
     feed = self.create_feed_dict(data_batch, dropout=1)
     answer_pointer_rep = sess.run(
         fetches=util.tuple_to_list(*self.answer_pointer_rep),
         feed_dict=feed)
     pred = du.get_answer_from_span(answer_pointer_rep[1])
     return pred
Пример #3
0
    def debug(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch)
        debug_output = sess.run(util.tuple_to_list(*self.train_op),
                                feed_dict=feed)

        logger.debug("Gradient {}".format(debug_output[1]))
        logger.debug("Loss {}".format(debug_output[2]))
Пример #4
0
 def predict_on_batch(self, sess, data_batch):
     feed = self.create_feed_dict(data_batch)
     answer_pointer_rep = sess.run(
         fetches = util.tuple_to_list(*self.answer_pointer_rep),
         feed_dict=feed
     )
     pred = answer_pointer_rep[1]
     return pred
Пример #5
0
 def debug(self, sess, data_batch):
     feed = self.create_feed_dict(data_batch, dropout=1)
     final_rep = self.train_op
     output = sess.run(fetches=util.tuple_to_list(*final_rep),
                       feed_dict=feed)
     # logger.info(output)
     logger.info("grad_norms: {}".format(output[1]))
     logger.info("loss: {}".format(output[2]))
     logger.info("pred: {}".format(output[3]))
Пример #6
0
    def train_on_batch(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch)
        train_op_output = sess.run(util.tuple_to_list(*self.train_op),
                                   feed_dict=feed)

        grad_norm = train_op_output[1]
        loss = train_op_output[2]
        retain = train_op_output[3]
        return grad_norm, loss, retain
Пример #7
0
    def train_on_batch(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch, dropout=1)

        train_op = sess.run(fetches=util.tuple_to_list(*self.train_op),
                            feed_dict=feed)

        grad_norm = train_op[1]
        loss = train_op[2]

        return grad_norm, loss, 0.
Пример #8
0
    def debug_shape(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch)

        train_op_output = sess.run(
            fetches = util.tuple_to_list(*self.train_op),
            feed_dict=feed
        )
        for i, tensor in enumerate(self.train_op):
            if tensor.name.startswith("debug_"):
                logger.debug("Shape of {} == {}".format(tensor.name[6:], train_op_output[i]))
Пример #9
0
    def train_on_batch(self, sess, data_batch):
        feed = self.create_feed_dict(data_batch)

        train_op = sess.run(
            fetches = util.tuple_to_list(*self.train_op),
            feed_dict=feed
        )

        loss = train_op[1]
        pred = train_op[2]

        return loss, pred
Пример #10
0
 def summary_success(self, sess, data_batch):
     feed = self.create_feed_dict(data_batch)
     debug_output = sess.run(util.tuple_to_list(*self.train_op),
                             feed_dict=feed)
     return debug_output[3]