# \donttest{
if (torch::torch_is_installed()){
# load ALS data
ig<- alsData$graph
data<- alsData$exprs
data<- transformData(data)$data
group<- alsData$group
#...with train-test (0.5-0.5) samples
set.seed(123)
train<- sample(1:nrow(data), 0.5*nrow(data))
#ncores<- parallel::detectCores(logical = FALSE)
start<- Sys.time()
dnn0<- SEMdnn(ig, data[train, ], thr = NULL,
#hidden = 5*K, link = "selu", bias = TRUE,
hidden = c(10,10,10), link = "selu", bias = TRUE,
validation = 0, epochs = 32, ncores = 2)
end<- Sys.time()
print(end-start)
#str(dnn0, max.level=2)
dnn0$fit$fitIdx
parameterEstimates(dnn0$fit)
gplot(dnn0$graph)
table(E(dnn0$graph)$color)
#...with source nodes -> graph layer structure -> sink nodes
#Topological layer (TL) ordering
K<- c(12, 5, 3, 2, 1, 8)
K<- rev(K[-c(1,length(K))]);K
ig1<- mapGraph(ig, type="source"); gplot(ig1)
start<- Sys.time()
dnn1<- SEMdnn(ig1, data[train, ], thr = NULL,
hidden = 5*K, link = "selu", bias = TRUE,
validation = 0, epochs = 32, ncores = 2)
end<- Sys.time()
print(end-start)
#Visualization of the neural network structure
nn1 <- dnn1$model[[1]][[1]]
nplot(nn1, bias=FALSE)
#str(dnn1, max.level=2)
dnn1$fit$fitIdx
mean(dnn1$fit$Psi)
parameterEstimates(dnn1$fit)
gplot(dnn1$graph)
table(E(dnn1$graph)$color)
#...with a categorical outcome, a train set (0.5) and a validation set (0.2)
outcome<- factor(ifelse(group == 0, "control", "case")); table(outcome)
start<- Sys.time()
dnn2<- SEMdnn(ig, data[train, ], outcome[train], thr = NULL,
#hidden = 5*K, link = "selu", bias = TRUE,
hidden = c(10,10,10), link = "selu", bias = TRUE,
validation = 0.2, epochs = 32, ncores = 2)
end<- Sys.time()
print(end-start)
#str(dnn2, max.level=2)
dnn2$fit$fitIdx
parameterEstimates(dnn2$fit)
gplot(dnn2$graph)
table(E(dnn2$graph)$color)
table(V(dnn2$graph)$color)
}
# }
Run the code above in your browser using DataLab