def load_files_and_tracks(path_name):
    connect_to_db()
    print("Directory: ", end="")
    path = str(input())
    try:
        files = get_files_in_path(path_name=path_name)
        for f in files:

            try:
                file = File()
                print('Processing file:{}'.format(f))
                file.parse_filename(filename=f)
                file.add_raw_file(filename=f)
                file.save()
                tracks = file.load_local_file(filename=f)
                for track in tracks:
                    track.save()
            except AssertionError:
                print("Unable to load file:{}".format(f))
            finally:
                print("File loaded")
    except FileNotFoundError:
        print("Invalid directory")
    disconnect_to_db()
示例#2
0
from Networks.diffusion_coefficient_network import DiffusionCoefficientNetworkModel
from Tools.db_connection import disconnect_to_db, connect_to_db
import matplotlib.pyplot as plt
import numpy as np

if __name__ == "__main__":
    connect_to_db()
    lower_limit = 15
    upper_limit = 1500
    nets = DiffusionCoefficientNetworkModel.objects(track_length__in=range(
        lower_limit, upper_limit),
                                                    hiperparams_opt=False)
    count = 0
    for net in nets:
        print(net.id)
        epochs = np.arange(1, len(net.history['mse']) + 1)
        plt.plot(epochs, net.history['mse'])
        if net.history['mse'][-1] >= 0.006:
            count += 1
    print('Must be retrained:{}'.format(count))

    plt.xlabel('Epochs')
    plt.ylabel('MSE')
    plt.show()

    for net in nets:
        if net.history['mse'][-1] >= 0.006:
            net.net_params['lr'] = 6e-8
            # net.net_params['lr'] = 5e-7

            net.train_network()