Exemple #1
0
def get_user():
    #if no user file - create one using email - for user setup
    tmp = fm.read_file("data/user.txt")
    if tmp != None:
        return tmp
    else:
        print("\nUser File Not Found: Please use aeneas to init a user file")
        exit(0)
Exemple #2
0
def get_training_data():
    file_name = "data/scipio_training_data.txt"
    data = fm.read_file(file_name)
    data_clean = []
    #vet data
    for line in data:
        data_clean.append(line.strip('\n').split(':'))
    return data_clean
Exemple #3
0
def check_progress():
    tmp = fm.read_file("data/progress.txt")
    if tmp != None:
        return tmp
    else:
        print("Progress File Not Found: Creating One...")
        fm.write_file("data/progress.txt", '', "w+")
        print("Progress File Created!")
        return []
Exemple #4
0
def get_user():
    tmp = fm.read_file("data/user.txt")
    if tmp != None:
        return tmp
    else:
        print("User File Not Found: Creating One...")
        user_email = input('User Email: ') + "\n"
        print("Retrieving User Token...")
        token = json.dumps(get_token(user_email))
        print("Token Collected!")
        fm.write_file("data/user.txt", [user_email, token], 'w')
        return [user_email, token]
Exemple #5
0
def load_weights(file_name):
    #default location for data files
    data = fm.read_file('data/' + str(file_name))
    if data == None:
        #alt location
        data = fm.read_file(str(file_name))
    temp = []
    for item in data:
        temp.append([
            float(x)
            for x in str(item.split(':')[1]).replace('\n', '').replace(
                '[', '').replace(']', '').split(', ')
        ])

    i = 0
    for perceptron in perceptrons:
        perceptron.weight = temp[i]
        i = i + 1

    print("Weights loaded!")
    return
Exemple #6
0
def print_title():
    lines = fm.read_file("titles/aeneas_title.txt")
    for line in lines:
        print(line.strip("\n"))
    print("\t\t\t\t\t\t\t<3 valtyr")
Exemple #7
0
def execute():
    counter = 0
    streak = 0
    top_streak = 0
    time_start = time.time()
    while True:
        (targets, blob) = request()

        #set all outputs
        for percep in perceptrons:
            percep.input = compute_frequency(blob, percep.chunk)
            percep.get_output()

        count = {}
        for percep in perceptrons:
            if percep.output == 1 and targets.__contains__(percep.label):
                if percep.label in count.keys():
                    count[percep.label] = count[percep.label] + 1
                else:
                    count[percep.label] = 1

        try:
            guess = max(count, key=count.get)

            #if confidence low ie low fire rate .. raise and pull
            net_conf = int(count.get(guess))
            if net_conf <= confidence:
                print('low answer confidence...low fire[' +
                      str(int(count.get(guess))) + "]")
                raise ('')

            print("Guess:\t" + guess + '\tConfidence: ' + str(net_conf))

            response = solve(guess)

            correct_resp = response.json()['correct']
            target = response.json()['target']
            accuracy = response.json()['accuracy']

            try:
                hash_resp = response.json()['hash']
                print("HASH COLLECTED!")
                time_stop = time.time()
                time_total = time_stop - time_start
                save_hash("Streak: " +
                          str(fm.read_file('data/top_streak.txt')) +
                          "Correct: " + str(correct_resp) + "\tAccuracy: " +
                          str(accuracy) + "\tTotal Time: " + str(time_total) +
                          "\nHash: " + hash_resp + "\n")
                # ask_hash(email)
            except:
                hash_resp = "None"

            print('Answer: ' + target + '\tNumber: ' + str(correct_resp) +
                  "\tAccuracy: " + str(accuracy))

            if (target == guess):
                streak = streak + 1
                # if streak > top_streak:
                #     top_streak=streak
                print("streak: " + str(streak) + '\n')
            else:
                if int(fm.read_file('data/top_streak.txt')) < streak:
                    fm.write_file('data/top_streak.txt', top_streak, 'w+')
                print('streak reset...\n')
                streak = 0

            for percep in perceptrons:
                percep.adjust_weight(target)
                percep.mod = random.choice([0, 1])

            counter = counter + 1

            save_training_data(target, blob)

            #save weights every 10 cycles
            if counter % 10 == 0:
                print("Weights saved!")
                save_weights()

        except:
            pass
    return
Exemple #8
0
def print_title():
    lines = fm.read_file("titles/scipio_title.txt")
    for line in lines:
        print(line.strip('\n'))
    print("     <3 valtyr")
    return