Example #1
0
    def __init__(self,
                 model,
                 holdout,
                 batch_size=30,
                 iters_per_spin=10,
                 validation_period=10):
        self.problem = rr.BanditValueProblem(model=model)

        self.tr_base = adel.BasicDataset()
        self.val_base = adel.BasicDataset()
        self.holdout = adel.HoldoutWrapper(training=self.tr_base,
                                           holdout=self.val_base,
                                           **holdout)

        self.tr_sampler = adel.DatasetSampler(base=self.tr_base,
                                              method='uniform')
        self.tr_sampled = adel.LabeledDatasetTranslator(base=self.tr_sampler)
        self.tr_data = adel.LabeledDatasetTranslator(base=self.tr_base)
        self.val_data = adel.LabeledDatasetTranslator(base=self.val_base)
        self.reporter = adel.LabeledDatasetTranslator(base=self.holdout)

        self.iters_per_spin = iters_per_spin
        self.val_period = validation_period
        self.batch_size = batch_size

        self.spin_counter = 0

        self.error_plotter = rr.LineSeriesPlotter(
            title='Value error over time %s' % model.scope,
            xlabel='Spin iter',
            ylabel='Mean squared loss')
        self.value_plotter = rr.LineSeriesPlotter(title='Values %s' %
                                                  model.scope,
                                                  xlabel='Spin iter',
                                                  ylabel='Value')
Example #2
0
    def __init__(self,
                 problem,
                 holdout,
                 batch_size=30,
                 iters_per_spin=10,
                 validation_period=10):
        self.problem = problem

        self.train_base = adel.BasicDataset()
        self.val_base = adel.BasicDataset()
        self.holdout = adel.HoldoutWrapper(training=self.train_base,
                                           holdout=self.val_base,
                                           **holdout)

        self.train_sampler = adel.DatasetSampler(base=self.train_base,
                                                 method='uniform')
        self.train_sampled = adel.LabeledDatasetTranslator(
            base=self.train_sampler)

        self.train_data = adel.LabeledDatasetTranslator(base=self.train_base)
        self.val_data = adel.LabeledDatasetTranslator(base=self.val_base)
        self.reporter = adel.LabeledDatasetTranslator(base=self.holdout)

        self.iters_per_spin = iters_per_spin
        self.val_period = validation_period
        self.batch_size = batch_size

        self.spin_counter = 0

        self.error_plotter = LineSeriesPlotter(
            title='Value error over time %s' % self.scope,
            xlabel='Spin iter',
            ylabel=self.problem.loss_type)
        self.value_plotter = ScatterPlotter(title='Value parities %s' %
                                            self.scope,
                                            xlabel='Target value',
                                            ylabel='Estimated value')
        self.plottables = [self.error_plotter, self.value_plotter]

        if self.problem.model.using_image:
            # TODO HACK
            self.filters = self.problem.params[0]
            n_filters = int(self.filters.shape[-1])
            self.filter_plotter = FilterPlotter(n_filters)
            self.plottables.append(self.filter_plotter)
Example #3
0
    def __init__(self,
                 classifier,
                 holdout,
                 optimizer,
                 visualize=True,
                 vis_res=10):

        self.classifier = classifier
        self.optimizer = optim.parse_optimizers(**optimizer)

        self.training_base = adel.BasicDataset()
        self.tuning_base = adel.BasicDataset()
        self.tuning_holdout = adel.HoldoutWrapper(training=self.training_base,
                                                  holdout=self.tuning_base,
                                                  **holdout)
        self.report_binary = adel.BinaryDatasetTranslator(self.tuning_holdout)

        self.training_binary = adel.BinaryDatasetTranslator(self.training_base)
        self.tuning_binary = adel.BinaryDatasetTranslator(self.tuning_base)

        self.validation_base = adel.BasicDataset()
        self.validation_binary = adel.BinaryDatasetTranslator(
            self.validation_base)

        self.update_counter = 0

        self.visualize = visualize
        self.vis_res = vis_res

        if self.visualize:
            # TODO Put scope in name
            self.heat_plotter = ImagePlotter(vmin=0,
                                             vmax=1,
                                             title='Classifier')
            self.point_plotter = LineSeriesPlotter(other=self.heat_plotter)
            self.error_plotter = LineSeriesPlotter(
                title='Logistic losses over time',
                xlabel='Spin iter',
                ylabel='Logistic loss')
            self.roc_plotter = LineSeriesPlotter(title='ROC',
                                                 xlabel='False positive rate',
                                                 ylabel='True positive rate')