Exemple #1
0
def main(opts):
    RECEIVED_PARAMS = nni.get_next_parameter()
    LOG.debug(RECEIVED_PARAMS)
    if 'onlyIncoming' == opts.mode:
        PARAMS = cudnnLstm.generate_default_onlyIncoming_params(opts.dataType)
    elif 'both' == opts.mode:
        PARAMS = cudnnLstm.generate_default_whole_params(opts.dataType)
    PARAMS.update(RECEIVED_PARAMS)
    try:
        X_train_raw, y_train, X_test_raw, y_test, labelMap = loadTrainAndTestData(
            opts.input, PARAMS['data_dim'], opts.dataType, opts.mode)
        NUM_CLASS = len(set(y_test))

        X_train = X_train_raw.reshape(X_train_raw.shape[0],
                                      X_train_raw.shape[1], 1)
        X_test = X_test_raw.reshape(X_test_raw.shape[0], X_test_raw.shape[1],
                                    1)
        y_train = np_utils.to_categorical(y_train, NUM_CLASS)
        y_test = np_utils.to_categorical(y_test, NUM_CLASS)

        lstm_model = LSTM(opts, PARAMS)
        modelPath = lstm_model.train(PARAMS, X_train, y_train, NUM_CLASS)
        lstm_model.test(X_test, y_test, NUM_CLASS, modelPath)
    except Exception as e:
        LOG.exception(e)
        raise
Exemple #2
0
def loadData(opts, PARAMS):
    X_train, y_train, X_test, y_test, labelMap = prepareData.loadTrainAndTestData(
        opts.input, PARAMS['data_dim'], opts.dataType, opts.mode)
    NUM_CLASS = len(set(y_test))
    y_train = np_utils.to_categorical(y_train, NUM_CLASS)
    y_test = np_utils.to_categorical(y_test, NUM_CLASS)

    return X_train, y_train, X_test, y_test, labelMap, NUM_CLASS
def loadData(opts, params):
    X_train_raw, y_train, X_test_raw, y_test, labelMap = loadTrainAndTestData(
        opts.input, params['data_dim'], opts.dataType)
    NUM_CLASS = len(set(y_test))

    X_train = X_train_raw.reshape(X_train_raw.shape[0], X_train_raw.shape[1],
                                  1)
    X_test = X_test_raw.reshape(X_test_raw.shape[0], X_test_raw.shape[1], 1)
    y_train = np_utils.to_categorical(y_train, NUM_CLASS)
    y_test = np_utils.to_categorical(y_test, NUM_CLASS)

    return X_train, y_train, X_test, y_test, labelMap, NUM_CLASS
Exemple #4
0
def main(opts):
    RECEIVED_PARAMS = nni.get_next_parameter()
    LOG.debug(RECEIVED_PARAMS)
    if 'onlyIncoming' == opts.mode:
        PARAMS = sae.generate_default_onlyIncoming_params(opts.dataType)
    elif 'both' == opts.mode:
        PARAMS = sae.generate_default_whole_params(opts.dataType)
    PARAMS.update(RECEIVED_PARAMS)
    try:
        X_train, y_train, X_test, y_test, labelMap = prepareData.loadTrainAndTestData(opts.input, PARAMS['data_dim'], opts.dataType, opts.mode)
        NUM_CLASS = len(set(y_test))

        y_train = np_utils.to_categorical(y_train, NUM_CLASS)
        y_test = np_utils.to_categorical(y_test, NUM_CLASS)

        sae_model = SAE(opts, PARAMS)
        modelPath = sae_model.train(PARAMS, X_train, y_train, NUM_CLASS)
        sae_model.test(X_test, y_test, NUM_CLASS, modelPath)
    except Exception as e:
        LOG.exception(e)
        raise