Ejemplo n.º 1
0
def image_summaries(dist, target, name='image', max_batch=10):
    summaries = []
    with tf.variable_scope(name):
        empty_frame = 0 * target[:max_batch, :1]
        image = dist.mode()[:max_batch]
        target = target[:max_batch]
        change = tf.concat([empty_frame, image[:, 1:] - image[:, :-1]], 1)
        error = image - target
        summaries.append(
            image_strip_summary.image_strip_summary('prediction', image))
        summaries.append(
            image_strip_summary.image_strip_summary('change',
                                                    (change + 1) / 2))
        summaries.append(
            image_strip_summary.image_strip_summary('error', (error + 1) / 2))
        # Concat prediction and target vertically.
        frames = tf.concat([target, image], 2)
        # Stack batch entries horizontally.
        frames = tf.transpose(frames, [1, 2, 0, 3, 4])
        s = shapelib.shape(frames)
        frames = tf.reshape(frames, [s[0], s[1], s[2] * s[3], s[4]])
        summaries.append(
            gif_summary.gif_summary('animation',
                                    frames[None],
                                    max_outputs=1,
                                    fps=20))
    return summaries
Ejemplo n.º 2
0
def image_summaries(dist, target, name='image', max_batch=10):
    summaries = []
    with tf.variable_scope(name):
        empty_frame = 0 * target[:max_batch, :1]
        image = dist.mode()[:max_batch]
        change = tf.concat([empty_frame, image[:, 1:] - image[:, :-1]], 1)
        error = image[:max_batch] - target[:max_batch]
        summaries.append(
            image_strip_summary.image_strip_summary('prediction', image))
        summaries.append(
            image_strip_summary.image_strip_summary('change',
                                                    (change + 1) / 2))
        summaries.append(
            image_strip_summary.image_strip_summary('error', (error + 1) / 2))
    return summaries
Ejemplo n.º 3
0
def data_summaries(data, postprocess_fn, histograms=False, name='data'):
  summaries = []
  with tf.variable_scope(name):
    if histograms:
      for key, value in data.items():
        if key in ('image',):
          continue
        summaries.append(tf.summary.histogram(key, data[key]))
    image = data['image']
    if postprocess_fn:
      image = postprocess_fn(image)
    summaries.append(image_strip_summary.image_strip_summary('image', image))
  return summaries
Ejemplo n.º 4
0
def data_summaries(data, postprocess_fn, histograms=False, name='data'):
    summaries = []
    with tf.variable_scope(name):
        if histograms:
            for key, value in data.items():
                if key in ('image', ):
                    continue
                summaries.append(tf.summary.histogram(key, data[key]))
        image = data['image']
        if postprocess_fn:
            image = postprocess_fn(image)
        summaries.append(
            image_strip_summary.image_strip_summary('image', image))
    summaries.append(
        tf.summary.scalar(
            'action_mean',
            tf.reduce_mean(tf.reduce_sum(tf.square(data['action']), axis=-1))))
    return summaries