def __init__(self, layer_structure, net_name): # load the cifar-10 images and their corresponding labels cifar_data = load_cifar.images_to_volumes("image_data/data_batch_1") test_data = load_cifar.images_to_volumes("image_data/data_batch_2") self.image_volumes = cifar_data[0] self.image_labels = cifar_data[1] test_volumes = test_data[0] test_labels = test_data[1] self.net_name = net_name # generate the layers based off of layer definitions from user self.layers = [] if layer_structure == None: print "~~ Loading network '%s' from saved_networks directory..." % (net_name) self.pretrained = True self.layer_structure = self.load_structure() self.build_layers(self.layer_structure) self.load_params() print "~~ Done!" else: print "~~ Initializing untrained network..." self.pretrained = False self.layer_structure = layer_structure self.build_layers(self.layer_structure) self.initialize_params() print "~~ Done!" print
def __init__(self, network, learning_rate): self.network = network self.learning_rate = learning_rate self.weight_decay = 0.0001 # accumulators for the gradient and parameters (used in adadelta) self.grad_accumated = [] self.update_accumated = [] # import all the batches batch_one = load_cifar.images_to_volumes("image_data/data_batch_1") batch_two = load_cifar.images_to_volumes("image_data/data_batch_2") batch_three = load_cifar.images_to_volumes("image_data/data_batch_3") batch_four = load_cifar.images_to_volumes("image_data/data_batch_4") batch_test = load_cifar.images_to_volumes("image_data/data_batch_5") # define all the volumes and their labels self.vol_one = batch_one[0] self.lab_one = batch_one[1] self.vol_two = batch_two[0] self.lab_two = batch_two[1] self.vol_three = batch_three[0] self.lab_three = batch_three[1] self.vol_four = batch_four[0] self.lab_four = batch_four[1] self.vol_test = batch_test[0] self.lab_test = batch_test[1]