def train(epochs, seed):
    batch_size = 128
    num_class = 55
    save_path = ((base_name + '_seed') + str(seed))
    model_path = '_'
    (X_train, y_train, X_test) = load_data()
    (ids_train_split, ids_valid_split) = train_test_split(np.arange(X_train.shape[0]), random_state=42, test_size=0.05, stratify=y_train)
    X_train_cv = X_train[ids_train_split]
    y_train_cv = y_train[ids_train_split]
    X_holdout = X_train[ids_valid_split]
    Y_holdout = y_train[ids_valid_split]
    weight_path = (('model/' + save_path) + '.hdf5')
    callbacks = get_callbacks(weight_path, patience=16)
    gen = mix_generator(X_train_cv, y_train_cv, 'input/train', batch_size)
    gen_val = train_generator(X_holdout, Y_holdout, 'input/train', batch_size, shuffle=False)
    gen_val_pred = test_generator(X_holdout, 'input/train', batch_size, shuffle=False)
    gen_tst_pred = test_generator(X_test, 'input/test', batch_size, shuffle=False)
    model = get_model(num_class)
    model.fit_generator(generator=gen, steps_per_epoch=np.ceil((X_train_cv.shape[0] / batch_size)), epochs=epochs, verbose=1, callbacks=callbacks, validation_data=gen_val, validation_steps=np.ceil((X_holdout.shape[0] / batch_size)))
    model.load_weights(filepath=weight_path)
    score = model.evaluate_generator(generator=gen_val, steps=np.ceil((X_holdout.shape[0] / batch_size)))
    print('Valid loss:', score[0])
    print('Valid accuracy:', score[1])
    pred_valid = model.predict_generator(generator=gen_val_pred, steps=np.ceil((X_holdout.shape[0] / batch_size)))
    pred_test = model.predict_generator(generator=gen_tst_pred, steps=np.ceil((X_test.shape[0] / batch_size)))
    submission = pd.DataFrame({'id': X_test, 'predict': np.argmax(pred_test, axis=1)})
    submit_path = (((((('output/submission' + save_path) + '_val_loss') + str(score[0])) + '_val_acc') + str(score[1])) + '.tsv')
    submission.to_csv(submit_path, index=False, header=False, sep='\t')
    np.save((('input/' + base_name) + '_valid.npy'), pred_valid)
    np.save((('input/' + base_name) + '_test.npy'), pred_test)
def train(epochs, seed):
    batch_size = 128
    num_class = 55
    save_path = ((base_name + '_seed') + str(seed))
    model_path = '_'
    (X_train, y_train, X_test) = load_data()
    (ids_train_split, ids_valid_split) = train_test_split(np.arange(X_train.shape[0]), random_state=42, test_size=0.05, stratify=y_train)
    X_train_cv = X_train[ids_train_split]
    y_train_cv = y_train[ids_train_split]
    X_holdout = X_train[ids_valid_split]
    Y_holdout = y_train[ids_valid_split]
    weight_path = (('model/' + save_path) + '.hdf5')
    callbacks = get_callbacks(weight_path, patience=16)
    gen = mix_generator(X_train_cv, y_train_cv, 'input/train', batch_size)
    gen_val = train_generator(X_holdout, Y_holdout, 'input/train', batch_size, shuffle=False)
    gen_val_pred = test_generator(X_holdout, 'input/train', batch_size, shuffle=False)
    gen_tst_pred = test_generator(X_test, 'input/test', batch_size, shuffle=False)
    model = get_model(num_class)
    model.fit_generator(generator=gen, steps_per_epoch=np.ceil((X_train_cv.shape[0] / batch_size)), epochs=epochs, verbose=1, callbacks=callbacks, validation_data=gen_val, validation_steps=np.ceil((X_holdout.shape[0] / batch_size)))
    model.load_weights(filepath=weight_path)
    score = model.evaluate_generator(generator=gen_val, steps=np.ceil((X_holdout.shape[0] / batch_size)))
    print('Valid loss:', score[0])
    print('Valid accuracy:', score[1])
    pred_valid = model.predict_generator(generator=gen_val_pred, steps=np.ceil((X_holdout.shape[0] / batch_size)))
    pred_test = model.predict_generator(generator=gen_tst_pred, steps=np.ceil((X_test.shape[0] / batch_size)))
    submission = pd.DataFrame({'id': X_test, 'predict': np.argmax(pred_test, axis=1)})
    submit_path = (((((('output/submission' + save_path) + '_val_loss') + str(score[0])) + '_val_acc') + str(score[1])) + '.tsv')
    submission.to_csv(submit_path, index=False, header=False, sep='\t')
    np.save((('input/' + base_name) + '_valid.npy'), pred_valid)
    np.save((('input/' + base_name) + '_test.npy'), pred_test)