def test_associative_recall_data(): INPUT_DIMENSION_SIZE = 6 ITEM_SIZE = 4 MAX_EPISODE_SIZE = 20 TRAINING_SIZE = 100 MAX_INPUT_LENGTH = (ITEM_SIZE + 1) * (MAX_EPISODE_SIZE + 2) print(MAX_INPUT_LENGTH) # item = dataset.generate_associative_recall_items(input_size, item_size, episode_size) # print(item) print('Generating data sets...') input_sequence, output_sequence = dataset.generate_associative_recall_data_set( INPUT_DIMENSION_SIZE, ITEM_SIZE, MAX_EPISODE_SIZE, TRAINING_SIZE) # print input_sequence # print output_sequence print(input_sequence.shape) print(output_sequence.shape) for i in range(TRAINING_SIZE): # print(output_sequence[i].transpose()) # print(input_sequence[i].transpose()) visualization.show_associative_recall_data( output_sequence[i].transpose(), input_sequence[i].transpose(), "Output sequence $y^{(t)}$", "Input sequence $x^{(t)}$", "../experiment/associative_recall_%2d.pdf" % i)
# RNN = recurrent.SimpleRNN # RNN = recurrent.GRU RNN = recurrent.LSTM HIDDEN_SIZE = 128 * 4 LAYERS = 1 # LAYERS = MAX_REPEAT_TIMES BATCH_SIZE = 1024 FOLDER = "experiment_results/associative_recall/" if not os.path.isdir(FOLDER): os.makedirs(FOLDER) print("create folder: %s" % FOLDER) print() print(time.strftime('%Y-%m-%d %H:%M:%S')) print('Generating data sets...') train_X, train_Y = dataset.generate_associative_recall_data_set( INPUT_DIMENSION_SIZE, ITEM_SIZE, MAX_EPISODE_SIZE, TRAINING_SIZE) valid_X, valid_Y = dataset.generate_associative_recall_data_set( INPUT_DIMENSION_SIZE, ITEM_SIZE, MAX_EPISODE_SIZE, TRAINING_SIZE / 5) matrix_list = [] matrix_list.append(train_X[0].transpose()) matrix_list.append(train_Y[0].transpose()) matrix_list.append(train_Y[0].transpose()) name_list = [] name_list.append("Input") name_list.append("Target") name_list.append("Predict") show_matrix = visualization.PlotDynamicalMatrix(matrix_list, name_list) random_index = np.random.randint(1, 128, 20) for i in range(20): matrix_list_update = []