예제 #1
0
    def __init__(self, train):
        dataset_number = env.DATASET_NUMBER
        num_dataset_to_use = env.NUM_DATASET_TO_USE
        chords_in_vector = env.CHORDS_IN_BAR * dataset_number
        chord_length = env.CHORD_LENGTH

        num_layers = env.NUM_LAYERS
        num_hidden = env.NUM_HIDDEN
        batch_size = env.BATCH_SIZE
        epoch = env.EPOCH
        dropout_pb = env.DROPOUT_PB

        with tf.variable_scope(str(dataset_number) + str(num_dataset_to_use) + str(chords_in_vector) + str(chord_length)):

            cell_type = tf.nn.rnn_cell.GRUCell

            # Number of examples, number of input, dimension of each input
            data = tf.placeholder(tf.float64, [None, chords_in_vector, chord_length])
            target = tf.placeholder(tf.float64, [None, 2])

            cell = cell_type(num_hidden)

            reader = Reader()

            if train:
                reader.read_training_data(dataset_number, num_dataset_to_use)
                reader.read_testing_data(dataset_number, num_dataset_to_use)
                # make sure it has the correct format for the RNN
                reader.convert_to_rnn_format(chords_in_vector, chord_length)

                self.model = model = MultiRNNModel(cell, data, target, train, batch_size, epoch, dropout_pb, num_hidden, num_layers, reader.training_attributes, reader.training_labels, reader.testing_attributes, reader.testing_labels)
            else:
                #reader.read_training_data(dataset_number, 0)
                #reader.read_testing_data(dataset_number, num_dataset_to_use)
                # make sure it has the correct format for the RNN
                #reader.convert_to_rnn_format(chords_in_vector, chord_length)
                self.model = model = MultiRNNModel(cell, data, target, train, batch_size, epoch, dropout_pb, num_hidden, num_layers)
예제 #2
0
from pprint import pprint

np.set_printoptions(precision=6, suppress=True)

# GRU

dataset_number = 8
num_dataset_to_use = 1000
chords_in_vector = 4 * dataset_number
chord_length = 33

reader = Reader()
reader.read_training_data(dataset_number, num_dataset_to_use)
reader.read_testing_data(dataset_number, num_dataset_to_use)
# make sure it has the correct format for the RNN
reader.convert_to_rnn_format(chords_in_vector, chord_length)

cell_index = 0

batch_size = 1000

num_hidden = 60
num_layers = 10
epoch = 67

# Number of examples, number of input, dimension of each input
data = tf.placeholder(tf.float64, [None, chords_in_vector, chord_length])
target = tf.placeholder(tf.float64, [None, 2])

model = MultiRNNModel(data, target, 0.1, num_hidden=num_hidden, num_layers=num_layers)