def train(self): """ Store a copy of every image in the iterator. """ Experiment.train(self) start = time.time() gabor = GaborRegion((144, 192), rotations=3, initial_wavelength=3, num_wavelengths=2) # Regions = [ GaborRegion, AndRegion, OrRegion (classifier) ] self.network = AndOrNetwork((144,192), num_regions=1, input_region = gabor) and_region = self.network.regions[1] classifier = self.network.get_classifier() i = 0 while self.image_iterator.has_next(): image, category, img_idx = self.image_iterator.next() gabor.do_inference(numpy.array(image)) active_nodes = gabor.get_active_nodes() pos = and_region.create_node((0,0), cxns = active_nodes) classifier.create_node(category, pos) i += 1 if i % self.PRINT_INCR == 0: print "Iter:", i and_region.prepare_for_inference() classifier.prepare_for_inference() num_cxns = and_region.get_num_cxns() + classifier.get_num_cxns() print "Number of connections:", num_cxns elapsed = (time.time() - start) print "Training time:", elapsed print "Time per category:", (elapsed / i) print colored("Training complete", "green")