luz icon indicating copy to clipboard operation
luz copied to clipboard

How to check the model parameters ?

Open danli349 opened this issue 11 months ago • 0 comments

Hello:

Is there a way to check the model parameters ? Thanks

library(ISLR2)
library(torch)
library(luz) # high-level interface for torch
library(torchvision) # for datasets and image transformation
library(torchdatasets) # for datasets we are going to use
library(zeallot)
torch_manual_seed(13)

modnn <- nn_module(
  initialize = function(input_size) {
    self$hidden <- nn_linear(input_size, 50)
    self$activation <- nn_relu()
    self$dropout <- nn_dropout(0.4)
    self$output <- nn_linear(50, 1)
  },
  forward = function(x) {
    x %>% 
      self$hidden() %>% 
      self$activation() %>% 
      self$dropout() %>% 
      self$output()
  }
)

x <- model.matrix(Salary ~ . - 1, data = Gitters) %>% scale()


modnn <- modnn %>% 
  setup(
    loss = nn_mse_loss(),
    optimizer = optim_rmsprop,
    metrics = list(luz_metric_mae())
  ) %>% 
  set_hparams(input_size = ncol(x))

modnn

<luz_module_generator>

summary(modnn)

Error in object[[i]]: object of type 'closure' is not subsettable Traceback:

  1. summary.default(modnn)

danli349 avatar Jan 02 '25 22:01 danli349