countParams: countParams

View source: R/utilities.R

countParamsR Documentation

countParams

Description

Count the number of trainable parameters in a model.

Usage

countParams(model, test_data)

Arguments

model

instantiated model object as nn_module subclass as opposed to luz fitted object.

test_data

Example tensor of the correct shape for the model being explored.

Details

Count the number of trainable parameters in an instantiated model subclassed from nn_module().

Value

Counts of model parameters.

Examples


require(torch)
model <- defineUNet(inChn = 4,
                    nCls = 3,
                    actFunc = "lrelu",
                    useAttn = TRUE,
                    useSE = TRUE,
                    useRes = TRUE,
                    useASPP = TRUE,
                    useDS = FALSE,
                    enChn = c(16,32,64,128),
                    dcChn = c(128,64,32,16),
                    btnChn = 256,
                    dilRates=c(6,12,18),
                    dilChn=c(256,256,256,256),
                    negative_slope = 0.01,
                    seRatio=8)
 t1 <- torch::torch_rand(c(12,4,128,128))
 params <- countParams(model, t1)
 

geodl documentation built on Nov. 12, 2025, 5:07 p.m.