Beispiel #1
0
import numpy as np

dtype = torch.FloatTensor
''' Net Settings'''
In_Nodes = 5567  ###number of genes
Pathway_Nodes = 860  ###number of pathways
Hidden_Nodes = 100  ###number of hidden nodes
Out_Nodes = 30  ###number of hidden nodes in the last hidden layer
''' Initialize '''
Initial_Learning_Rate = 0.03
L2_Lambda = 0.001
Num_EPOCHS = 15000
###sub-network setup
Dropout_Rate = [0.7, 0.5]
''' load data and pathway '''
pathway_mask = load_pathway("../data/pathway_mask.csv", dtype)
x, ytime, yevent, age = load_data("../data/entire_data.csv", dtype)

outpath = "../results/InterpretCoxPASNet.pt"
'''train Cox-PASNet for model interpretation'''
InterpretCoxPASNet(x, age, ytime, yevent, pathway_mask, \
     In_Nodes, Pathway_Nodes, Hidden_Nodes, Out_Nodes, \
     Initial_Learning_Rate, L2_Lambda, Num_EPOCHS, Dropout_Rate, outpath)
'''load trained Cox-PASNet'''
net = Cox_PASNet(In_Nodes, Pathway_Nodes, Hidden_Nodes, Out_Nodes,
                 pathway_mask)
net.load_state_dict(torch.load(outpath))
###if gpu is being used
if torch.cuda.is_available():
    net.cuda()
###
Beispiel #2
0
else:
	device = torch.device('cpu')
dtype = torch.FloatTensor

In_Nodes = 5075
Pathway_Nodes = 100 
Hidden_Nodes = 80
Out_Nodes = 30

Initial_Learning_Rate = [0.00001, 0.000075]
L2_Lambda = [0.01, 0.005, 0.001]
num_epochs = 5000
Num_EPOCHS = 20000
Dropout_Rate = [0.7, 0.5]
path='./Data/Multiple/'
pathway_mask = load_pathway(path+"pathway_module_input.csv", dtype)

x_train, ytime_train, yevent_train = load_data_without(path+"train.csv", dtype)
x_valid, ytime_valid, yevent_valid= load_data_without(path+"test.csv", dtype)
x_test, ytime_test, yevent_test= load_data_without(path+"validation.csv", dtype)
opt_l2_loss = 0
opt_lr_loss = 0
opt_loss = torch.Tensor([float("Inf")])
if torch.cuda.is_available():
	opt_loss = opt_loss.cuda()

opt_c_index_va = 0
opt_c_index_tr = 0
for l2 in L2_Lambda:
	for lr in Initial_Learning_Rate:
		loss_train, loss_valid, c_index_tr, c_index_va = trainDeepOmixNet_without(x_train, ytime_train, yevent_train, \
from Train import trainPASNet
import torch
import numpy as np
''' PASNet Settings'''
In_Nodes = 4359  ###number of genes
Pathway_Nodes = 574  ###number of pathways
Hidden_Nodes = 100  ###number of hidden nodes
Out_Nodes = 2  ###one is for LTS, and the other is for non-LTS
''' Initial Settings for Empirical Search '''
Learning_Rates = [0.05, 0.01, 0.007, 0.005, 0.001, 0.0007, 0.0005, 0.0001]
L2_Lambdas = [3e-4, 5e-4, 7e-4, 1e-3, 3e-3, 5e-3]
Dropout_Rates = [0.8, 0.7]  ###sub-network setup
nEpochs = 5000  ###for empirical search
''' load data and pathway '''
dtype = torch.FloatTensor
pathway_mask = load_pathway("data/gbm_binary_pathway_mask_reactome_574.csv",
                            dtype)
###loaded data were split for empirical search only
x_train, y_train = load_data("data/std_train.csv", dtype)
x_valid, y_valid = load_data("data/std_valid.csv", dtype)

opt_l2 = 0
opt_lr = 0
opt_loss = torch.Tensor([float("Inf")])
###if gpu is being used
if torch.cuda.is_available():
    opt_loss = opt_loss.cuda()
###

##grid search the optimal hyperparameters using train and validation data
for lr in Learning_Rates:
    for l2 in L2_Lambdas: