from self_organising_map import SelfOrganisingMap from voronoi import Voronoi from tools import SpacialGenerator, Logger import sys, getopt # the 'main' routine if __name__ == "__main__": try: opts, args = getopt.getopt(sys.argv[1:], "x:y:n:l:m:s:e:d", [ "dim_x=", "dim_y=", "neurons=", "learning=", "min_euclidean=", "spacial=", "epochs=" ]) except getopt.GetoptError: sys.exit(2) Logger.output("options: {0}".format(opts)) Logger.output("arguments: {0}".format(args)) neurons = 10 x = 800 y = 600 learning_rate = 0.1 min_euclidean = 0.01 epochs = 1000 spacial = SpacialGenerator.line for opt, arg in opts: if opt in ("-x", "--dim_x"): x = int(arg) if opt in ("-y", "--dim_y"): y = int(arg)
def __init__(self, neurons = 40, threshold = -1): Logger.output("creating network") self.neurons = [Neuron(i, neurons, threshold) for i in range(neurons)] Logger.output("created network with {0} neurons".format(len(self.neurons)))
from self_organising_map import SelfOrganisingMap from voronoi import Voronoi from tools import SpacialGenerator, Logger import sys, getopt # the 'main' routine if __name__ == "__main__": try: opts, args = getopt.getopt(sys.argv[1:], "x:y:n:l:m:s:e:d", ["dim_x=", "dim_y=", "neurons=", "learning=", "min_euclidean=", "spacial=", "epochs="]) except getopt.GetoptError: sys.exit(2) Logger.output("options: {0}".format(opts)) Logger.output("arguments: {0}".format(args)) neurons = 10 x = 800 y = 600 learning_rate = 0.1 min_euclidean = 0.01 epochs = 1000 spacial = SpacialGenerator.line for opt, arg in opts: if opt in ("-x", "--dim_x"): x = int(arg) if opt in ("-y", "--dim_y"): y = int(arg) if opt in ("-n", "--neurons"):
if inn == None: inn = urls if neurons == None: neurons = 40 hophop = HopfieldNet(neurons, threshold) hophop.learn(inn) hophop.test(inn) if retrieve != None: hophop.retrieve(retrieve) if __name__ == "__main__": """ the main routine """ try: opts, args = getopt.getopt(sys.argv[1:], "i:n:r:t:dm", ["input=", "manual", "neurons=", "retrieve=", "threshold="]) except getopt.GetoptError: sys.exit(2) Logger.output("options: {0}".format(opts)) Logger.output("arguments: {0}".format(args)) neurons = None inn = None retrieve = None threshold = -1 for opt, arg in opts: if opt in ("--manual"): inn = args if opt in ("-n", "--neurons"): neurons = int(arg) if opt == '-d': Logger.debug = True if opt in ("-r", "--retrieve"):