Exemplo n.º 1
0
 def __init__(self,
     model_file = 'model/model.h5',
     dictionaries = ('model/note2int', 'model/int2note')):
     self.model = load_model(model_file)
     self.graph = tf.get_default_graph()
     self.note2int = load(dictionaries[0])
     self.int2note = load(dictionaries[1])
Exemplo n.º 2
0
def data():
    x_train = dm.load("dataset/X_train")
    y_train = dm.load("dataset/y_train")
    x_val = dm.load("dataset/X_val")
    y_val = dm.load("dataset/y_val")
    return x_val,y_val,x_val,y_val
Exemplo n.º 3
0
import datamanager as dm

history_dir = 'history/'

history1 = dm.load(history_dir +
                   'GRU256_GRU64_GRU512_BATCH32_EMBEDDING20')['history']
history2 = dm.load(history_dir +
                   'GRU256_GRU64_GRU512_BATCH32_EMBEDDING40')['history']
history3 = dm.load(history_dir +
                   'GRU256_GRU64_GRU512_BATCH32_EMBEDDING60')['history']
history4 = dm.load(history_dir +
                   'GRU256_GRU64_GRU512_BATCH32_EMBEDDING80')['history']
history5 = dm.load(history_dir +
                   'GRU256_GRU64_GRU512_BATCH32_EMBEDDING100')['history']

from matplotlib import pyplot as plt
import numpy as np

# Loss plot:
plt.subplot(121)
plt.axis([0, 19, 0, 2.8])
plt.title('Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.grid(axis='x')
plt.grid(axis='y')
plt.xticks(np.arange(0, 20, 2))
plt.yticks(np.arange(0, 2.9, 0.2))

plt.plot(history1['loss'],
         color='#000000',
Exemplo n.º 4
0
import datamanager as dm

history_dir = 'history/'

history1 = dm.load(history_dir + 'three_256_64_128_64')['history']
history2 = dm.load(history_dir + 'three_256_64_512_32')['history']
history3 = dm.load(history_dir + 'three_32_256_64_128')['history']
history4 = dm.load(history_dir + 'three_512_128_256_64')['history']
history5 = dm.load(history_dir + 'three_64_64_64_32')['history']

from matplotlib import pyplot as plt
import numpy as np

# Loss plot:
plt.subplot(121)
plt.axis([0,19,0,2.8])
plt.title('Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.grid(axis='x')
plt.grid(axis='y')
plt.xticks(np.arange(0,20,2))
plt.yticks(np.arange(0,2.9,0.2))

plt.plot(history1['loss'],      color='#000000', linestyle='-',  label='Train loss GRU(256)-GRU(64)-GRU(128) batch-64')
plt.plot(history1['val_loss'],  color='#000000', linestyle='--', label='Validation loss GRU(256)-GRU(64)-GRU(128) batch-64')
plt.plot(history2['loss'],      color='#0000ff', linestyle='-',  label='Train loss GRU(256)-GRU(64)-GRU(512) batch-32')
plt.plot(history2['val_loss'],  color='#0000ff', linestyle='--', label='Validation loss GRU(256)-GRU(64)-GRU(512) batch-32')
plt.plot(history3['loss'],      color='#00ff00', linestyle='-',  label='Train loss GRU(32)-GRU(256)-GRU(64) batch-128')
plt.plot(history3['val_loss'],  color='#00ff00', linestyle='--', label='Validation loss GRU(32)-GRU(256)-GRU(64) batch-128')
plt.plot(history4['loss'],      color='#00ffff', linestyle='-',  label='Train loss GRU(512)-GRU(128)-GRU(256) batch-64')
Exemplo n.º 5
0
import datamanager as dm

history_dir = 'history_GRU-128-tanh_rmsprop_128-batch_25-epochs/'

history1 = dm.load(history_dir + '1-layer_test006_loss_acc')
history2 = dm.load(history_dir + '2-layer_test006_loss_acc')
history3 = dm.load(history_dir + '3-layer_test006_loss_acc')
history4 = dm.load(history_dir + '4-layer_test006_loss_acc')
history5 = dm.load(history_dir + '5-layer_test006_loss_acc')
history6 = dm.load(history_dir + '6-layer_test006_loss_acc')
history7 = dm.load(history_dir + '7-layer_test006_loss_acc')
history8 = dm.load(history_dir + '8-layer_test006_loss_acc')
history9 = dm.load(history_dir + '9-layer_test006_loss_acc')
history10 = dm.load(history_dir + '10-layer_test006_loss_acc')

from matplotlib import pyplot as plt
import numpy as np

# Loss plot:
plt.subplot(221)
plt.axis([0, 24, 0, 2.8])
plt.title('Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.grid(axis='y')
plt.xticks(np.arange(0, 25, 2))
plt.yticks(np.arange(0, 2.9, 0.2))

plt.plot(history1['loss'],
         color='#000000',
         linestyle='-',
Exemplo n.º 6
0
batch_size = args.batch_size
epochs = args.epochs
max_layers = args.max_layers
min_layers = args.min_layers
verbosity = args.verbosity

weights_dir = 'weights006_GRU-' + str(rnn_units) + '-' + rnn_activation + '_' + optimizer + '_' + str(batch_size) + '-batch_' + str(epochs) + '-epochs'
if not os.path.exists(weights_dir):
    os.makedirs(weights_dir)
history_dir = 'history_GRU-' + str(rnn_units) + '-' + rnn_activation + '_' + optimizer + '_' + str(batch_size) + '-batch_' + str(epochs) + '-epochs'
if not os.path.exists(history_dir):
    os.makedirs(history_dir)


# Load data
X_train = dm.load("dataset/X_train")
y_train = dm.load("dataset/y_train")
X_val = dm.load("dataset/X_val")
y_val = dm.load("dataset/y_val")
X_test = dm.load("dataset/X_test")
y_test = dm.load("dataset/y_test")


for i in range(min_layers, max_layers+1):
    # Make model
    model = Sequential()
    counter = i
    while counter > 0:
        if counter == 1 and counter == i:
            model.add( GRU( units=rnn_units, activation=rnn_activation, input_shape=(X_train.shape[1], X_train.shape[2]) ) )
        elif counter == 1: