import tensorflow as tf

                metrics = self.evaluate('validation', mute=True)
                tf.logging.info(
                        'Iter {:4d}: loss {:.4f}'.format(i, loss) +
                        ''.join([', {} {:.4f}'.format(m, metrics[m]) for m in metrics]))

                if output_dir is not None:
                    train_writer.add_summary(summaries, i)
                    metrics_summaries = tf.Summary(value=[
                        tf.Summary.Value(tag=m, simple_value=v)
                        for m, v in metrics.items()])
                    train_writer.add_summary(metrics_summaries, i)
        tf.logging.info('Training finished')

    def predict(self, data, keys='*', batch=False):
        assert set(data.keys()) >= set(self.data_shape.keys())
        if isinstance(keys, str):
            if keys == '*':
                op = self.pred_out  # just gather all outputs
            else:
                op = self.pred_out[keys]
        else:
            op = {k: self.pred_out[k] for k in keys}
