コード例 #1
0
ファイル: main.py プロジェクト: JDwangmo/coprocessor
    input_length=sentence_padding_length,
    num_labels=len(index_to_label),
    conv1_filter_type=config['l1_conv_filter_type'],
    conv2_filter_type=config['l2_conv_filter_type'],
    full_connected_layer_units=config['full_connected_layer_units'],
    output_dropout_rate=config['output_dropout_rate'],
    nb_epoch=config['nb_epoch'],
    nb_batch=config['nb_batch'],
    earlyStoping_patience=config['earlyStoping_patience'],
    lr=config['lr'],
)
onehot_cnn.print_model_descibe()

onehot_cnn.fit((train_X_feature, train_y),
               (test_X_feature, test_y))
onehot_cnn.accuracy((train_X_feature, train_y), transform_input=False)

logging.debug('=' * 20)
# ****************************************************************
# ------------- region end : 3、构建onehot编码 -------------
# ****************************************************************


logging.debug('=' * 20)
# ------------------------------------------------------------------------------
# -------------- region end : 预测 ---------------
# ------------------------------------------------------------------------------

end_time = timeit.default_timer()
print 'end! Running time:%ds!' % (end_time - start_time)
logging.debug('=' * 20)
コード例 #2
0
ファイル: main.py プロジェクト: JDwangmo/coprocessor
            # (hidden2, 0.5, 'relu', 'none'),
        ],
        embedding_dropout_rate=0.,
        nb_epoch=30,
        nb_batch=5,
        earlyStoping_patience=20,
        lr=1e-2,
    )
    onehot_cnn.print_model_descibe()

    print(onehot_cnn.fit(
        (train_X_feature, train_y),
        (test_X_feature, test_y)))
# onehot_cnn.accuracy((train_X_feature, train_y), transform_input=False)

y_pred, is_correct, accu, f1, test_loss = onehot_cnn.accuracy((test_X_feature, test_y))
result_file_path = 'result/onehot_%s_%d.csv' % (feature_type, rand_seed)
data_util.save_result(test_data, predict=y_pred, is_correct=is_correct, path=result_file_path)

logging.debug('=' * 20)
# ****************************************************************
# ------------- region end : 3、构建onehot编码 -------------
# ****************************************************************


logging.debug('=' * 20)
# ------------------------------------------------------------------------------
# -------------- region end : 预测 ---------------
# ------------------------------------------------------------------------------

end_time = timeit.default_timer()
コード例 #3
0
ファイル: main.py プロジェクト: JDwangmo/coprocessor
    full_connected_layer_units=config['full_connected_layer_units'],
    output_dropout_rate=config['output_dropout_rate'],
    nb_epoch=config['nb_epoch'],
    batch_size=config['nb_batch'],
    earlyStoping_patience=config['earlyStoping_patience'],
    lr=config['lr'],
)
# np.random.seed(0)
print(np.random.randint(0,100))
# quit()
onehot_cnn.print_model_descibe()


onehot_cnn.fit((train_X_feature, train_y),
               (test_X_feature, test_y))
onehot_cnn.accuracy((train_X_feature, train_y), transform_input=False)
y_pred, is_correct, accu, f1 = onehot_cnn.accuracy((test_X_feature, test_y), transform_input=False)

test_data['PREDICT'] = [index_to_label[item] for item in y_pred]
test_data['is_correct'] = is_correct

data_util.save_data(test_data,'ttttt.csv')

logging.debug('=' * 20)
# ****************************************************************
# ------------- region end : 3、构建onehot编码 -------------
# ****************************************************************


logging.debug('=' * 20)
# ------------------------------------------------------------------------------