Exemplo n.º 1
0
    def _build_summary_op(self, results=None, features=None, labels=None):
        """Builds summaries for this model.

        The summaries are one value (or more) of:
            * (`ACTIVATIONS`, `VARIABLES`, `GRADIENTS`, `LOSS`, `LEARNING_RATE`)
        """
        summary_op = []
        for summary in self.summaries:
            if summary == summarizer.SummaryOptions.ACTIVATIONS:
                activations = get_tracked(tf.GraphKeys.ACTIVATIONS)
                summary_op += summarizer.add_activations_summary(activations)
            elif summary == summarizer.SummaryOptions.VARIABLES:
                variables = tf.trainable_variables()
                summary_op += summarizer.add_trainable_vars_summary(variables)
            elif summary == summarizer.SummaryOptions.GRADIENTS and self._clip_gradients > 0.0:
                summary_op += summarizer.add_gradients_summary(
                    self._grads_and_vars)
            elif summary == summarizer.SummaryOptions.LOSS:
                summary_op += summarizer.add_loss_summaries(
                    self._total_loss, self._loss)
            elif summary == summarizer.SummaryOptions.LEARNING_RATE:
                summary_op += summarizer.add_learning_rate_summaries()
            elif summary == summarizer.SummaryOptions.IMAGE_INPUT:
                summary_op += summarizer.add_image_summary(features,
                                                           op_name='inputs')
            elif summary == summarizer.SummaryOptions.IMAGE_RESULT:
                summary_op += summarizer.add_image_summary(results,
                                                           op_name='results')

        # no need to tf.summary.merge(summary_op), for now we merge all at hook level
        return summary_op
Exemplo n.º 2
0
    def _build_summary_op(self, results=None, features=None, labels=None):
        """Builds summaries for this model.

        The summaries are one value (or more) of:
            * (`ACTIVATIONS`, `VARIABLES`, `GRADIENTS`, `LOSS`, `LEARNING_RATE`)
        """
        summary_op = []
        for summary in self.summaries:
            if summary == summarizer.SummaryOptions.ACTIVATIONS:
                activations = get_tracked(tf.GraphKeys.ACTIVATIONS)
                summary_op += summarizer.add_activations_summary(activations)
            elif summary == summarizer.SummaryOptions.VARIABLES:
                variables = tf.trainable_variables()
                summary_op += summarizer.add_trainable_vars_summary(variables)
            elif summary == summarizer.SummaryOptions.GRADIENTS and self._clip_gradients > 0.0:
                summary_op += summarizer.add_gradients_summary(self._grads_and_vars)
            elif summary == summarizer.SummaryOptions.LOSS:
                summary_op += summarizer.add_loss_summaries(self._total_loss, self._loss)
            elif summary == summarizer.SummaryOptions.LEARNING_RATE:
                summary_op += summarizer.add_learning_rate_summaries()
            elif summary == summarizer.SummaryOptions.IMAGE_INPUT:
                summary_op += summarizer.add_image_summary(features, op_name='inputs')
            elif summary == summarizer.SummaryOptions.IMAGE_RESULT:
                summary_op += summarizer.add_image_summary(results, op_name='results')

        # no need to tf.summary.merge(summary_op), for now we merge all at hook level
        return summary_op