nplot: Create a plot for a neural network model

nplotR Documentation

Create a plot for a neural network model

Description

The function uses the plotnet function of the NeuralNetTools R package to draw a neural network plot and visualize the hidden layer structure.

Usage

nplot(object, hidden, bias = TRUE, sleep = 2, ...)

Arguments

object

A neural network model object

hidden

The hidden structure of the object

bias

A logical value, indicating whether to draw biases in the layers (default = FALSE).

sleep

Suspend plot display for a specified time (in secs, default = 2).

...

Currently ignored.

Details

The induced subgraph of the input graph mapped on data variables. Based on the estimated connection weights, if the connection weight W > 0, the connection is activated and it is highlighted in red; if W < 0, the connection is inhibited and it is highlighted in blue.

Value

The function invisibly returns the graphical objects representing the neural network architecture designed by NeuralNetTools.

Author(s)

Mario Grassi mario.grassi@unipv.it

References

Beck, M.W. 2018. NeuralNetTools: Visualization and Analysis Tools for Neural Networks. Journal of Statistical Software. 85(11):1-20.

Examples



if (torch::torch_is_installed()){

# load ALS data
ig<- alsData$graph
data<- alsData$exprs
data<- transformData(data)$data

#ncores<- parallel::detectCores(logical = FALSE)
dnn0 <- SEMdnn(ig, data, train=1:nrow(data), algo = "layerwise",
			hidden = c(10, 10, 10), link = "selu", bias =TRUE,
			epochs = 32, patience = 10, verbose = TRUE)

 #Visualize the neural networks per each layer of dnn0
 nplot(dnn0, hidden = c(10, 10, 10), bias = FALSE)
}



SEMdeep documentation built on Nov. 10, 2025, 5:06 p.m.