Example #1
0
def load_data(data_dir, verbose=False):

    dataset = data_utils.get_CIFAR10_data(data_dir)
    if verbose:
        for k, v in dataset.items():
            print("%s : %s " % (k, v.shape))

    return dataset
Example #2
0
def load_data(data_dir, verbose=False):

    if verbose is True:
        print("Loading data from %s" % data_dir)

    dataset = data_utils.get_CIFAR10_data(data_dir)
    if verbose:
        for k, v in dataset.items():
            print("%s : %s " % (k, v.shape))

    return dataset
Example #3
0
    def load_data(self, data_dir: str) -> None:
        self.dataset = data_utils.get_CIFAR10_data(data_dir)
        self.train_data: Dict[str, Any] = {
            'X_train': self.dataset['X_train'][:self.num_train],
            'y_train': self.dataset['y_train'][:self.num_train],
            'X_val': self.dataset['X_val'][:self.num_train],
            'y_val': self.dataset['y_val'][:self.num_train]
        }

        if self.verbose:
            for k, v in self.dataset.items():
                print("%s : %s " % (k, v.shape))
Example #4
0
def overfit():
    # Data
    dataset = data_utils.get_CIFAR10_data('datasets/cifar-10-batches-py')
    # Hyperparameters
    # for now we just some random params, not found by search
    reg = 1e-2
    weight_scale = 2e-3
    learning_rate = 1e-3
    # Training parameters
    num_epochs = 40
    #train_sizes = [50, 100, 150, 200]
    train_sizes = [200, 400, 800, 1000, 1500]

    solv_dict = {}
    for size in train_sizes:
        overfit_data = {
            'X_train': dataset['X_train'][:size],
            'y_train': dataset['y_train'][:size],
            'X_val':   dataset['X_val'][:size],
            'y_val':   dataset['y_val'][:size]
        }
        model = convnet.ConvNetLayer(hidden_dims=[256],
                                     num_filters=[16],
                                     filter_size=5,
                                     reg=reg,
                                     weight_scale=weight_scale)
        solv = solver.Solver(model,
                             overfit_data,
                             num_epochs=num_epochs,
                             optim_config={'learning_rate': learning_rate})
        print("Overfitting on %d examples in %d epochs using the following network" % (size, num_epochs))
        print(model)
        solv.train()
        dkey = 'size_%d' % size
        solv_dict[dkey] = solv
        # Check that we can actually overfit

    # Plot the results
    fig, ax = vis_solver.get_train_fig()
    vis_solver.plot_solver_compare(ax, solv_dict)
    plt.show()