from preprocess import get_test_train_data
from save_load import get_last_file_number
from save_load import load
from model import accuracy, loss
from keras import backend
import sys, os
import tensorflow as tf
from utils import visualize_layers 

if __name__ == '__main__':
    
    file = "F:\Projects\python\self_driving_game\data\dataset_mini.pz"
    if len(sys.argv)<=1: count = None
    else: count = int(sys.argv[1]);
    
    # Load model
    exp_folder = 'exp_' + '{0:03d}'.format(get_last_file_number(prefix='exp_', suffix=''))
    model = load(count, path=exp_folder)

    # Visualize model
    x_train, x_test, y_train, y_test = get_test_train_data(file, 10, tanh=True)
    visualization_folder = exp_folder + '/visualization'
    if not os.path.exists(visualization_folder): os.makedirs(visualization_folder)

    visualize_layers(model, x_test, path=visualization_folder)
    print('Visualization done...!')
示例#2
0
if __name__ == '__main__':

    # # Print output to file
    # outfolder = 'exp_' + '{0:03d}'.format(get_last_file_number(prefix='exp_', suffix='') + 1); os.makedirs(outfolder)
    # outfile = outfolder + '/' + 'train_' + '{0:03d}'.format(get_last_file_number(path=outfolder) + 1) + '.log'
    # print('Printing to logfile at', outfile)
    # sys.stdout = open(outfile, 'w+')

    # Add title to logfile for identification
    # if len(sys.argv)>1: print('Title:',sys.argv[1],'\n\n')

    # Get test and train data
    file = os.environ['DATA_DIR'] + "/dataset_75p_gray.pz"
    x_train, x_test, y_train, y_test = get_test_train_data(file,
                                                           80000,
                                                           tanh=False)
    # x_train, x_test, y_train, y_test = get_test_train_data(file, 1000, tanh=False)

    learning_rate = 0.0005
    models = ['relu_with_scaled_sigmoid']
    drop_rates = [0.1]

    for i in range(len(models)):
        for j in range(len(drop_rates)):

            # Print output to file
            outfolder = 'exp_' + '{0:03d}'.format(
                get_last_file_number(prefix='exp_', suffix='') + 1)
            os.makedirs(outfolder)
            outfile = outfolder + '/' + 'train_' + '{0:03d}'.format(