Ejemplo n.º 1
0
    def visualize(self,
                  train_loader,
                  val_loader,
                  tensorboard=None,
                  epoch=None,
                  **kwargs):
        visualizations = {}

        # visualize pred
        fig, _ = vis.plot_predictions(self, train_loader, key="pred")
        visualizations["predictions/pred-train"] = fig
        if val_loader is not None:
            fig, _ = vis.plot_predictions(self, val_loader, key="pred")
            visualizations["predictions/pred-val"] = fig

        return visualizations
Ejemplo n.º 2
0
    def visualize(self,
                  train_loader,
                  val_loader,
                  tensorboard=None,
                  epoch=None,
                  **kwargs):
        visualizations = {}

        # gradient norm tensorboard histograms
        if tensorboard is not None:
            vis.ce_gradient_norm_histogram(self,
                                           train_loader,
                                           tensorboard,
                                           epoch,
                                           name='train-ce-grad')
            if val_loader is not None:
                vis.ce_gradient_norm_histogram(self,
                                               val_loader,
                                               tensorboard,
                                               epoch,
                                               name='val-ce-grad')

        # add gradient pair plots
        if train_loader.dataset.dataset_name == 'mnist':
            for p in [(0, 1), (4, 9)]:
                fig, _ = vis.ce_gradient_pair_scatter(self,
                                                      train_loader,
                                                      d1=p[0],
                                                      d2=p[1])
                visualizations['gradients/train-ce-scatter-{}-{}'.format(
                    p[0], p[1])] = fig
                if val_loader is not None:
                    fig, _ = vis.ce_gradient_pair_scatter(self,
                                                          val_loader,
                                                          d1=p[0],
                                                          d2=p[1])
                    visualizations['gradients/val-ce-scatter-{}-{}'.format(
                        p[0], p[1])] = fig

        # visualize pred
        fig, _ = vis.plot_predictions(self, train_loader, key='pred')
        visualizations['predictions/pred-train'] = fig
        if val_loader is not None:
            fig, _ = vis.plot_predictions(self, val_loader, key='pred')
            visualizations['predictions/pred-val'] = fig

        return visualizations
Ejemplo n.º 3
0
    def visualize(self,
                  train_loader,
                  val_loader,
                  tensorboard=None,
                  epoch=None,
                  **kwargs):
        visualizations = super(PredictGradOutput,
                               self).visualize(train_loader, val_loader,
                                               tensorboard, epoch)

        # visualize q_label_pred
        fig, _ = vis.plot_predictions(self, train_loader, key='q_label_pred')
        visualizations['predictions/q-label-pred-train'] = fig
        if val_loader is not None:
            fig, _ = vis.plot_predictions(self, val_loader, key='q_label_pred')
            visualizations['predictions/q-label-pred-val'] = fig

        return visualizations
Ejemplo n.º 4
0
    def visualize(self,
                  train_loader,
                  val_loader,
                  tensorboard=None,
                  epoch=None,
                  **kwargs):
        visualizations = super(PredictGradOutputFixedFormWithConfusion,
                               self).visualize(train_loader, val_loader,
                                               tensorboard, epoch)

        # visualize the confusion matrix
        if tensorboard is not None:
            fig, _ = vis.plot_confusion_matrix(
                torch.softmax(self.Q_logits, dim=1))
            visualizations['confusion-matrix'] = fig

        # visualize q_label_pred
        fig, _ = vis.plot_predictions(self, train_loader, key='q_label_pred')
        visualizations['predictions/q-label-pred-train'] = fig
        if val_loader is not None:
            fig, _ = vis.plot_predictions(self, val_loader, key='q_label_pred')
            visualizations['predictions/q-label-pred-val'] = fig

        return visualizations