コード例 #1
0
def test_associative_recall_data():
    input_size = 6
    item_size = 3
    episode_size = 2
    max_episode_size = 6
    # item = dataset.generate_associative_recall_items(input_size, item_size, episode_size)
    # print(item)
    #
    #
    # input_sequence, output_sequence = dataset.generate_associative_recall_data(
    #     input_size, item_size, episode_size, max_episode_size)
    # print input_sequence
    # print output_sequence

    training_size = 10
    train_X, train_Y = dataset.generate_repeat_copy_data_set(
        input_size, item_size, max_episode_size, training_size)

    print(train_X.shape)
    print(train_Y.shape)
    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)

    for i in range(training_size):
        matrix_list_update = []
        matrix_list_update.append(train_X[i].transpose())
        matrix_list_update.append(train_Y[i].transpose())
        matrix_list_update.append(train_Y[i].transpose())
        show_matrix.update(matrix_list_update, name_list)
        show_matrix.save(
            "../experiment/associative_recall_data_training_%2d.png" % i)
コード例 #2
0
train_X, train_Y = dataset.generate_copy_data_set(INPUT_DIMENSION_SIZE,
                                                  MAX_COPY_LENGTH,
                                                  TRAINING_SIZE)
valid_X, valid_Y = dataset.generate_copy_data_set(INPUT_DIMENSION_SIZE,
                                                  MAX_COPY_LENGTH,
                                                  TRAINING_SIZE / 10)

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 = []
    matrix_list_update.append(train_X[random_index[i]].transpose())
    matrix_list_update.append(train_Y[random_index[i]].transpose())
    matrix_list_update.append(train_Y[random_index[i]].transpose())
    show_matrix.update(matrix_list_update, name_list)
    show_matrix.save(FOLDER + "copy_data_training_%2d.png" % i)

print()
print(time.strftime('%Y-%m-%d %H:%M:%S'))
print('Build model...')
model = Sequential()
# "Encode" the input sequence using an RNN, producing an output of HIDDEN_SIZE
# note: in a situation where your input sequences have a variable length,