コード例 #1
0
def evaluate():
    print('Loading model...')
    model = load_model('')
    _, _, test_X, _, _, test_Y = split_frame()
    Y_original = test_Y
    Y_predict = np.array(model.predict(test_X))
    assert Y_original.shape == Y_predict.shape
    print Y_predict.shape
コード例 #2
0
def process():
    train_X, val_X, test_X, train_Y, val_Y, test_Y = split_frame()
    f = open('frame_content_data', 'wb')
    pickle.dump(train_X, f)
    pickle.dump(val_X, f)
    pickle.dump(test_X, f)
    pickle.dump(train_Y, f)
    pickle.dump(val_Y, f)
    pickle.dump(test_Y, f)
    f.close()
コード例 #3
0
def main():

    print('Loading model...')
    train_X, val_X, test_X, train_Y, val_Y, test_Y = split_frame()

    print('Building model...')
    model = Sequential()
    model.add(Dense(1024, activation='relu', input_shape=(20, )))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dense(30))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dense(30))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dropout(0.5))
    model.add(Dense(1024, activation='relu'))
    model.add(Dense(30))

    print('Compiling model...')
    model.compile(loss='mean_squared_error',
                  optimizer='adam',
                  metrics=['accuracy'],
                  sample_weight_mode=None)
    print(model.summary())

    print('Training model...')
    model.fit(train_X,
              train_Y,
              batch_size=128,
              epochs=15,
              validation_data=(val_X, val_Y),
              class_weight='auto',
              callbacks=[
                  EarlyStopping(monitor='val_loss', patience=2, verbose=0),
                  ModelCheckpoint(filepath='model1_weights.{epoch:02d}.hdf5',
                                  monitor='val_loss',
                                  save_best_only=True,
                                  verbose=0)
              ])

    score, acc = model.evaluate(test_X, test_Y, batch_size=128)
    print('Test score:', score)
    print('Test accuracy:', acc)
コード例 #4
0
ファイル: lstm_train_1.py プロジェクト: jefflai108/scale
def process():
	mfcc, vad = split_frame()
	f = open('mfcc_vad_3', 'wb')
	pickle.dump(mfcc, f)
	pickle.dump(vad, f)
	f.close()