Ejemplo n.º 1
0
    def on_plot_save(self, epoch, iter, logs={}):
        # import neuron sandbox
        # has to be here, can't be at the top, due to cyclical imports (??)
        # TODO: should just pass the function to compute the figures given the model and generator
        import neuron.sandbox as nrn_sandbox
        reload(nrn_sandbox)

        with timer.Timer('plot callback', self.verbose):
            if len(self.run.grid_size) == 3:
                collapse_2d = [0, 1, 2]
            else:
                collapse_2d = [2]

            exampl = nrn_sandbox.show_example_prediction_result(self.model,
                                                                self.generator,
                                                                self.run,
                                                                self.data,
                                                                test_batch_size=1,
                                                                test_model_names=None,
                                                                test_grid_size=self.run.grid_size,
                                                                ccmap=None,
                                                                collapse_2d=collapse_2d,
                                                                slice_nr=None,
                                                                plt_width=17,
                                                                verbose=self.verbose)

            # save, then close
            figs = exampl[1:]
            for idx, fig in enumerate(figs):
                dirn = "dirn_%d" % idx
                slice_nr = 0
                filename = self.savefilepath.format(epoch=epoch, iter=iter, axis=dirn, slice_nr=slice_nr)
                fig.savefig(filename)
            plt.close()
Ejemplo n.º 2
0
    def on_plot_save(self, epoch, iter, logs={}):
        # import neuron sandbox
        # has to be here, can't be at the top, due to cyclical imports (??)
        # TODO: should just pass the function to compute the figures given the model and generator
        import neuron.sandbox as nrn_sandbox
        reload(nrn_sandbox)

        with timer.Timer('plot callback', self.verbose):
            if len(self.run.grid_size) == 3:
                collapse_2d = [0, 1, 2]
            else:
                collapse_2d = [2]

            exampl = nrn_sandbox.show_example_prediction_result(self.model,
                                                                self.generator,
                                                                self.run,
                                                                self.data,
                                                                test_batch_size=1,
                                                                test_model_names=None,
                                                                test_grid_size=self.run.grid_size,
                                                                ccmap=None,
                                                                collapse_2d=collapse_2d,
                                                                slice_nr=None,
                                                                plt_width=17,
                                                                verbose=self.verbose)

            # save, then close
            figs = exampl[1:]
            for idx, fig in enumerate(figs):
                dirn = "dirn_%d" % idx
                slice_nr = 0
                filename = self.savefilepath.format(epoch=epoch, iter=iter, axis=dirn, slice_nr=slice_nr)
                fig.savefig(filename)
            plt.close()