本文整理汇总了Python中SdA.train_model方法的典型用法代码示例。如果您正苦于以下问题:Python SdA.train_model方法的具体用法?Python SdA.train_model怎么用?Python SdA.train_model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SdA
的用法示例。
在下文中一共展示了SdA.train_model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: import SdA [as 别名]
# 或者: from SdA import train_model [as 别名]
filename=data_dir + "GM12878_200bp_Data_3Cl_l2normalized_TestSet.txt";
test_set_x_org=numpy.loadtxt(filename,delimiter='\t',dtype='float32')
filename=data_dir + "GM12878_200bp_Classes_3Cl_l2normalized_TestSet.txt";
test_set_y_org=numpy.loadtxt(filename,delimiter='\t',dtype=object)
prev,test_set_y_org=cl.change_class_labels(test_set_y_org)
filename=data_dir + "GM12878_Features_Unique.txt";
features=numpy.loadtxt(filename,delimiter='\t',dtype=object)
rng=numpy.random.RandomState(1000)
# train
classifier,training_time=SdA.train_model(train_set_x_org=train_set_x_org, train_set_y_org=train_set_y_org,
valid_set_x_org=valid_set_x_org, valid_set_y_org=valid_set_y_org,
pretrain_lr=0.1,finetune_lr=0.1, alpha=0.01,
lambda_reg=0.00005, alpha_reg=0.5,
n_hidden=[64,64,32], corruption_levels=[0.01,0.01,0.01],
pretraining_epochs=5, training_epochs=1000,
batch_size=200, rng=rng)
# test
test_set_y_pred,test_set_y_pred_prob,test_time=SdA.test_model(classifier, test_set_x_org, batch_size=200)
print test_set_y_pred[0:20]
print test_set_y_pred_prob[0:20]
print test_time
# evaluate classification performance
perf,conf_mat=cl.perform(test_set_y_org,test_set_y_pred,numpy.unique(train_set_y_org))
print perf
print conf_mat
示例2:
# 需要导入模块: import SdA [as 别名]
# 或者: from SdA import train_model [as 别名]
pretrain_lr=0.1
finetune_lr=0.1
alpha=0.1
lambda_reg=0.00005
alpha_reg=0.5
n_hidden=[256,128,64]
corruption_levels=[0.01,0.01,0.01]
pretraining_epochs=5
training_epochs=1000
batch_size=100
# train, and extract features from training set
classifier,training_time=SdA.train_model(train_set_x_org=train_set_x_org, train_set_y_org=train_set_y_org,
valid_set_x_org=valid_set_x_org, valid_set_y_org=valid_set_y_org,
pretrain_lr=pretrain_lr,finetune_lr=finetune_lr, alpha=alpha,
lambda_reg=lambda_reg, alpha_reg=alpha_reg,
n_hidden=n_hidden, corruption_levels=corruption_levels,
pretraining_epochs=pretraining_epochs, training_epochs=training_epochs,
batch_size=batch_size, rng=rng)
# test the classifier
test_set_y_pred,test_set_y_pred_prob,test_time=SdA.test_model(classifier, test_set_x_org, batch_size=200)
# evaluate classification performance
perf_i,conf_mat_i=cl.perform(test_set_y_org,test_set_y_pred,numpy.unique(train_set_y_org))
print perf_i
print conf_mat_i
if i==0:
perf=perf_i
conf_mat=conf_mat_i
training_times=training_time