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

Wrappers for freeze() and unfreeze() #86

Merged
merged 5 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ export(float)
export(force_plot)
export(foreground_acc)
export(forget_mult_CPU)
export(freeze)
export(gan_critic)
export(gan_loss_from_func)
export(gauss_blur2d)
Expand Down Expand Up @@ -733,6 +734,7 @@ export(transformers)
export(trunc_normal_)
export(unet_config)
export(unet_learner)
export(unfreeze)
export(uniform_blur2d)
export(vgg11_bn)
export(vgg13_bn)
Expand Down
44 changes: 44 additions & 0 deletions R/freeze.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#' Freeze a model
#'
#' @param object A model
#'
#' @return Nothing
#' @export
#'
#' @examples
#' \donrun{
#' learnR %>% freeze()
#' }
freeze <- function(object){

args <- list()

do.call(object$freeze, args)
message("The model has been freezed")

}

#' Unfreeze a model
#'
#' @param object A model
#'
#' @return Nothing
#' @export
#'
#' @examples
#'
#' \donrun{
#' learnR %>% unfreeze()
#' }
unfreeze <- function(object){

args <- list()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there could be some parameters in learn$freeze(...). Could you add 3 dots after the object argument? Pass these dots to args, then, please. The same for freeze/unfreeze.
@Cdk29 could you make the necessary changes, so I merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henry090 I can yes. But the original fastai code cannot have additional argument so I am not sure it is a good idea : https://github.com/fastai/fastai/blob/master/fastai/learner.py#L521

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cdk29 It will not throw an error. It just allows passing something in case of future modifications. So, this is safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henry090 done !


do.call(object$unfreeze, args)
message("The model has been unfreezed")

}




Binary file modified inst/python/fastaibuilt/__pycache__/bs_finder.cpython-36.pyc
Binary file not shown.
22 changes: 22 additions & 0 deletions man/freeze.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/unfreeze.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.