Skip to content

Commit

Permalink
Merge pull request #48 from mlverse/release/v0.1.0
Browse files Browse the repository at this point in the history
Release/v0.1.0
  • Loading branch information
dfalbel committed Jun 16, 2021
2 parents d8c2ce7 + 51b3dbd commit 87c4064
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
^pkgdown$
^doc$
^Meta$
^cran-comments\.md$
^CRAN-RELEASE$
2 changes: 2 additions & 0 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This package was submitted to CRAN on 2021-06-16.
Once it is accepted, delete this file and tag the release (commit 1d00ae2).
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: luz
Title: Higher Level 'API' for 'torch'
Version: 0.0.0.9000
Version: 0.1.0
Authors@R: c(
person("Daniel", "Falbel", email = "[email protected]", role = c("aut", "cre", "cph")),
person(family = "RStudio", role = c("cph"))
Expand All @@ -12,9 +12,8 @@ Description: A high level interface for 'torch' providing utilities to reduce th
Howard et al. (2020) <arXiv:2002.04688>, 'Keras' by Chollet et al. (2015) and
'Pytorch Lightning' by Falcon et al. (2019) <doi:10.5281/zenodo.3828935>.
License: MIT + file LICENSE
URL: https://mlverse.github.io/luz, https://github.com/mlverse/luz
URL: https://mlverse.github.io/luz/, https://github.com/mlverse/luz
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
Imports:
Expand Down
6 changes: 6 additions & 0 deletions R/callbacks-interrupt.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ NULL
#' @note In general you don't need to use these callback by yourself because it's always
#' included by default in [fit.luz_module_generator()].
#'
#' @examples
#' interrupt_callback <- luz_callback_interrupt()
#'
#' @returns
#' A `luz_callback`
#'
#' @family luz_callbacks
#' @export
luz_callback_interrupt <- luz_callback(
Expand Down
6 changes: 6 additions & 0 deletions R/callbacks-profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
#' @note In general you don't need to use these callback by yourself because it's always
#' included by default in [fit.luz_module_generator()].
#'
#' @examples
#' profile_callback <- luz_callback_profile()
#'
#' @returns
#' A `luz_callback`
#'
#' @family luz_callbacks
#' @export
luz_callback_profile <- luz_callback(
Expand Down
11 changes: 11 additions & 0 deletions R/callbacks.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ luz_callback <- function(name = NULL, ..., private = NULL, active = NULL, parent
#' @note Printing can be disabled by passing `verbose=FALSE` to [fit.luz_module_generator()].
#'
#' @family luz_callbacks
#'
#' @returns
#' A `luz_callback`
#'
#' @export
luz_callback_progress <- luz_callback(
"progress_callback",
Expand Down Expand Up @@ -203,6 +207,10 @@ luz_callback_progress <- luz_callback(
#' used by default in [fit.luz_module_generator()].
#'
#' @family luz_callbacks
#'
#' @returns
#' A `luz_callback`
#'
#' @export
luz_callback_metrics <- luz_callback(
"metrics_callback",
Expand Down Expand Up @@ -272,6 +280,9 @@ luz_callback_metrics <- luz_callback(
#' @note In general you won't need to explicitly use the metrics callback as it's
#' used by default in [fit.luz_module_generator()].
#'
#' @returns
#' A `luz_callback`
#'
#' @family luz_callbacks
#' @export
luz_callback_train_valid <- luz_callback(
Expand Down
17 changes: 17 additions & 0 deletions R/metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ luz_metric <- function(name = NULL, ..., private = NULL, active = NULL,
#' metric$compute()
#' }
#' @export
#'
#'
#' @returns
#' Returns new Luz metric.
#'
#' @family luz_metrics
luz_metric_accuracy <- luz_metric(
abbrev = "Acc",
Expand Down Expand Up @@ -131,6 +136,10 @@ luz_metric_accuracy <- luz_metric(
#' metric$update(torch_rand(100), torch::torch_randint(0, 1, size = 100))
#' metric$compute()
#' }
#'
#' @returns
#' Returns new Luz metric.
#'
#' @family luz_metrics
#' @export
luz_metric_binary_accuracy <- luz_metric(
Expand Down Expand Up @@ -172,6 +181,8 @@ luz_metric_binary_accuracy <- luz_metric(
#' metric$update(torch_randn(100), torch::torch_randint(0, 1, size = 100))
#' metric$compute()
#' }
#' @returns
#' Returns new Luz metric.
#'
#' @family luz_metrics
#' @export
Expand Down Expand Up @@ -240,6 +251,8 @@ luz_metric_loss_average <- luz_metric(
#' metric$update(torch_randn(100), torch_randn(100))
#' metric$compute()
#' }
#' @returns
#' Returns new Luz metric.
#'
#' @family luz_metrics
#' @export
Expand Down Expand Up @@ -289,6 +302,10 @@ luz_metric_mse <- luz_metric(
#' Computes the root mean squared error.
#'
#' @family luz_metrics
#'
#' @returns
#' Returns new Luz metric.
#'
#' @export
luz_metric_rmse <- luz_metric(
inherit = luz_metric_mse,
Expand Down
2 changes: 2 additions & 0 deletions R/module-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ plot.luz_module_fitted <- function(x, ...) {
p <- p + ggplot2::geom_point() + ggplot2::geom_line()
p + ggplot2::facet_grid(metric ~ set, scales = "free_y")
}

globalVariables(c("epoch", "value"))
2 changes: 2 additions & 0 deletions R/module-print.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ print.luz_module_fitted <- function(x, ...) {
print(x$model)
}



14 changes: 13 additions & 1 deletion R/module.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#' @param metrics (`list`, optional) A list of metrics to be tracked during
#' the training procedure.
#'
#' @returns
#' A luz module that can be trained with [fit()].
#'
#' @family training
#'
#' @export
Expand Down Expand Up @@ -68,6 +71,9 @@ setup <- function(module, loss = NULL, optimizer = NULL, metrics = NULL) {
#'
#' @family set_hparam
#'
#' @returns
#' The same luz module
#'
#' @export
set_hparams <- function(module, ...) {
hparams <- rlang::list2(...)
Expand All @@ -87,6 +93,9 @@ set_hparams <- function(module, ...) {
#' `optim_adam` function is called with `optim_adam(parameters, lr=0.1)` when fitting
#' the model.
#'
#' @returns
#' The same luz module
#'
#' @family set_hparam
#' @export
set_opt_hparams <- function(module, ...) {
Expand Down Expand Up @@ -132,9 +141,12 @@ get_opt_hparams <- function(module) {
#'
#' @param ... Currently unused,
#'
#' @returns
#' A fitted object that can be saved with [luz_save()] and can be printed with
#' [print()] and plotted with [plot()].
#'
#' @importFrom generics fit
#' @export
#'
fit.luz_module_generator <- function(object, data, epochs = 10, callbacks = NULL,
valid_data = NULL, accelerator = NULL,
verbose = NULL, ...) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/mlverse/luz/workflows/R-CMD-check/badge.svg)](https://github.com/mlverse/luz/actions)
[![Codecov test coverage](https://codecov.io/gh/mlverse/luz/branch/master/graph/badge.svg)](https://codecov.io/gh/mlverse/luz?branch=master)
[![Discord](https://img.shields.io/discord/837019024499277855?logo=discord)](https://discord.gg/s3D5cKhBkx)
[![Discord](https://img.shields.io/discord/837019024499277855?logo=discord)](https://discord.com/invite/s3D5cKhBkx)
<!-- badges: end -->

luz is a higher level API for torch providing abstractions to allow for much less verbose training loops.
Expand Down
1 change: 1 addition & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
First release.
4 changes: 4 additions & 0 deletions man/fit.luz_module_generator.Rd

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

7 changes: 7 additions & 0 deletions man/luz_callback_interrupt.Rd

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

3 changes: 3 additions & 0 deletions man/luz_callback_metrics.Rd

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

7 changes: 7 additions & 0 deletions man/luz_callback_profile.Rd

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

3 changes: 3 additions & 0 deletions man/luz_callback_progress.Rd

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

3 changes: 3 additions & 0 deletions man/luz_callback_train_valid.Rd

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

3 changes: 3 additions & 0 deletions man/luz_metric_accuracy.Rd

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

4 changes: 4 additions & 0 deletions man/luz_metric_binary_accuracy.Rd

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

4 changes: 3 additions & 1 deletion man/luz_metric_binary_accuracy_with_logits.Rd

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

4 changes: 3 additions & 1 deletion man/luz_metric_mae.Rd

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

3 changes: 3 additions & 0 deletions man/luz_metric_rmse.Rd

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

3 changes: 3 additions & 0 deletions man/set_hparams.Rd

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

3 changes: 3 additions & 0 deletions man/set_opt_hparams.Rd

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

3 changes: 3 additions & 0 deletions man/setup.Rd

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

4 changes: 3 additions & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(testthat)
library(luz)

test_check("luz")
if (Sys.getenv("TORCH_TEST", unset = 0) == 1)
test_check("luz")

0 comments on commit 87c4064

Please sign in to comment.