Beispiel #1
0
    def setUp(self):
        # make a test dataset
        # print os.getcwd()
        data_dir_path = ds.get_data_dir_path()
        # print os.getcwd()
        os.chdir(r"%s" % data_dir_path)
        try:
            os.mkdir("TEST")
        except OSError:
            shutil.rmtree("TEST")
            os.mkdir("TEST")

        os.chdir("TEST")

        # make some files in the test dataset
        f = open("TEST.json", "w")
        f.write("{\"PtEtaPhi\":{\"train_file\":\"train_all_ptEtaPhi"
                ".txt\",\"test_file\":\"test_all_ptEtaPhi.txt\"},\""
                "Pt\":{\"train_file\":\"train_all_Pt.txt\",\"test_f"
                "ile\":\"test_all_Pt.txt\"},\"3v\":{\"train_file\":"
                "\"train_all_3v.txt\",\"test_file\":\"test_all_3v.t"
                "xt\"}}")
        f.close()
        os.system("touch train_all_ptEtaPhi.txt")
        os.system("touch test_all_ptEtaPhi.txt")
        os.system("touch train_all_Pt.txt")
        os.system("touch test_all_Pt.txt")
        os.system("touch train_all_3v.txt")
        os.system("touch test_all_3v.txt")

        os.system("touch PtEtaPhi.npz")

        os.chdir(data_dir_path)
Beispiel #2
0
    def setUp(self):
        # make a test dataset
        # print os.getcwd()
        data_dir_path = ds.get_data_dir_path()
        # print os.getcwd()
        os.chdir(r"%s" % data_dir_path)
        try:
            os.mkdir("TEST")
        except OSError:
            shutil.rmtree("TEST")
            os.mkdir("TEST")

        os.chdir("TEST")

        # make some files in the test dataset
        f = open("TEST.json", "w")
        f.write("{\"PtEtaPhi\":{\"train_file\":\"train_all_ptEtaPhi"
                ".txt\",\"test_file\":\"test_all_ptEtaPhi.txt\"},\""
                "Pt\":{\"train_file\":\"train_all_Pt.txt\",\"test_f"
                "ile\":\"test_all_Pt.txt\"},\"3v\":{\"train_file\":"
                "\"train_all_3v.txt\",\"test_file\":\"test_all_3v.t"
                "xt\"}}")
        f.close()
        os.system("touch train_all_ptEtaPhi.txt")
        os.system("touch test_all_ptEtaPhi.txt")
        os.system("touch train_all_Pt.txt")
        os.system("touch test_all_Pt.txt")
        os.system("touch train_all_3v.txt")
        os.system("touch test_all_3v.txt")

        os.system("touch PtEtaPhi.npz")

        os.chdir(data_dir_path)
Beispiel #3
0
    def setUp(self):
        # make a test dataset
        data_dir_path = ds.get_data_dir_path()
        os.chdir(data_dir_path)
        os.mkdir("TEST")
        os.chdir("TEST")

        # make some files in the test dataset
        os.system("touch test.experiment")
        os.system("touch is_experiment.experiment")
        os.system("touch is_not_experiment.test")
        os.system("touch PtEtaPhi.npz")

        os.chdir(data_dir_path)
Beispiel #4
0
    def setUp(self):
        # make a test dataset
        data_dir_path = ds.get_data_dir_path()
        os.chdir(data_dir_path)
        os.mkdir("TEST")
        os.chdir("TEST")

        # make some files in the test dataset
        os.system("touch test.experiment")
        os.system("touch is_experiment.experiment")
        os.system("touch is_not_experiment.test")
        os.system("touch PtEtaPhi.npz")

        os.chdir(data_dir_path)
Beispiel #5
0
    def test_get_path_to_dataset(self):
        """ Test the get_path_to_dataset function """
        # nominal case : just dataset_name
        data_dir_path = ds.get_data_dir_path()
        test_dataset_path = os.path.join(data_dir_path, "TEST")
        self.assertEqual(ds.get_path_to_dataset("TEST"), test_dataset_path)

        # nominal case: dataset_name and format
        test_format_path = os.path.join(test_dataset_path, "PtEtaPhi.npz")
        self.assertEqual(ds.get_path_to_dataset("TEST", "PtEtaPhi"),
                         test_format_path)

        # if the dataset doesn't exist
        with self.assertRaises(IOError):
            ds.get_path_to_dataset("some random folder")

        # if the format doesn't exist in a valid dataset
        with self.assertRaises(IOError):
            ds.get_path_to_dataset("TEST", "Spherical")
Beispiel #6
0
    def test_get_path_to_dataset(self):
        """ Test the get_path_to_dataset function """
        # nominal case : just dataset_name
        data_dir_path = ds.get_data_dir_path()
        test_dataset_path = os.path.join(data_dir_path, "TEST")
        self.assertEqual(ds.get_path_to_dataset("TEST"), test_dataset_path)

        # nominal case: dataset_name and format
        test_format_path = os.path.join(test_dataset_path,
                                                   "PtEtaPhi.npz")
        self.assertEqual(ds.get_path_to_dataset("TEST", "PtEtaPhi"),
                         test_format_path)

        # if the dataset doesn't exist
        with self.assertRaises(IOError):
            ds.get_path_to_dataset("some random folder")

        # if the format doesn't exist in a valid dataset
        with self.assertRaises(IOError):
            ds.get_path_to_dataset("TEST", "Spherical")
Beispiel #7
0
def set_configurations():
    print("What would you like to name this experiment setup?")
    print("*Note: this is used for naming the result files")
    name = raw_input(">> ")

    print("Which dataset would you like to run on?")
    ## Collect the names of the directories here
    # Selects dataset
    data_dir = get_data_dir_path()
    print(' '.join(filter(lambda x: path.isdir(path.join(data_dir, x)), os.listdir(data_dir))))
    dataset = raw_input(">> ")
    print()

    data_dir = get_path_to_dataset(dataset)
    with open(path.join(data_dir, dataset+".json")) as fp:
        j = json.load(fp)
    print("Which coordinates would you like to use?")
    print(' '.join(j.keys()))
    coords = raw_input(">> ")
    print()

    # Collect data files from that dataset and repeat question

    batch_size = raw_input("What will be your batch size?\n>> ")
    print()
    learning_rate = raw_input("What will be your learning rate?\n>> ")
    print()

    layers = raw_input("How many layers do you want?\n>> ")
    print()

    nodes = raw_input("How many nodes per layer do you want?\n>> ")
    print()

    print("How often do you want to save the model?")
    print("(Number of epochs)")
    sf = raw_input(">> ")
    print()

    print("How would you like to determine the end of the program:")
    print("1. After a certain number of epochs")
    print("2. After a certain amount of time")
    print("3. When the accuracy plateaus")
    print("*Note: You may select multiple, just separate them by spaces.")
    ending = filter(None, raw_input("[1/2/3] >> ").split())
    print()

    terms = {"epochs": None, "timeout": None, "plateau": {"m": None, "w": None}}
    if '1' in ending:
        terms['epochs'] = int(raw_input("How many epochs do you want to run?\n>> "))
        print()
    if '2' in ending:
        print("After how long do you want the program to be killed?")
        print("(Put units after the number, i.e. s/m/h/d/w/y)")
        time = raw_input(">> ")
        print()
        unit = time[-1]
        time = int(time[:-1])
        if unit == 'm':
            time *= 60
        elif unit == 'h':
            time *= 3600
        elif unit == 'd':
            time *= 3600*24
        elif unit == 'w':
            time *= 3600*24*7
        elif unit == 'y':
            time *= 3600*24*7*52
        terms['timeout'] = time
    if '3' in ending:
        print("For determining plateau:")
        x = raw_input("Over what interval would you like to measure the accuracy change?\n>> ")
        print()
        y = raw_input("What is the minimal increase in percentile you can accept over this interval?\n>> ")
        print()
        terms['plateau'] = dict(x=float(x), y=int(y))

    d = dict(save_name=name,
             dataset=dataset,
             coords=coords,
             batch_size=int(batch_size),
             learning_rate=float(learning_rate),
             layers=int(layers),
             nodes=int(nodes),
             save_freq=int(sf),
             terms=terms)
    return d
Beispiel #8
0
 def tearDown(self):
     data_dir_path = ds.get_data_dir_path()
     shutil.rmtree("TEST")
Beispiel #9
0
 def tearDown(self):
     data_dir_path = ds.get_data_dir_path()
     shutil.rmtree("TEST")