Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check the model parameters ? #152

Open
danli349 opened this issue Jan 2, 2025 · 0 comments
Open

How to check the model parameters ? #152

danli349 opened this issue Jan 2, 2025 · 0 comments

Comments

@danli349
Copy link

danli349 commented Jan 2, 2025

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant