-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docs_revision # Conflicts: # R/obtain_derivatives_list.R
- Loading branch information
Showing
65 changed files
with
1,432 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,14 @@ jobs: | |
build: | ||
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }} | ||
runs-on: ${{ matrix.config.os }} | ||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
name: ${{ matrix.config.os }} ${{ matrix.config.arch }} (${{ matrix.config.r }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: macOS-latest, tf: 'default', r: 'release'} | ||
- {os: macOS-latest, tf: 'default', r: 'release', arch: 'x86'} | ||
- {os: macOS-latest, tf: 'default', r: 'release', arch: 'arm64'} | ||
- {os: windows-latest, tf: 'default', r: 'release'} | ||
- {os: ubuntu-latest, tf: 'default', r: 'devel', http-user-agent: 'release'} | ||
- {os: ubuntu-latest, tf: 'default', r: 'release', covr: 'yes'} | ||
|
@@ -34,10 +35,11 @@ jobs: | |
with: | ||
extra-packages: any::rcmdcheck, any::covr, [email protected] | ||
needs: check, coverage | ||
- name: Miniconda + Tensorflow + Keras installation | ||
- name: Miniconda + Tensorflow + Keras + Torch installation | ||
run: | | ||
reticulate::install_miniconda() | ||
keras::install_keras(tensorflow = '${{ matrix.tf }}-cpu') | ||
torch::install_torch() | ||
shell: Rscript {0} | ||
|
||
- name: Check | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method(add_constraints,keras.engine.training.Model) | ||
S3method(add_constraints,luz_module_generator) | ||
S3method(fit,nn2poly) | ||
S3method(nn2poly,default) | ||
S3method(nn2poly,keras.engine.training.Model) | ||
S3method(nn2poly,list) | ||
S3method(plot_taylor_and_activation_potentials,default) | ||
S3method(plot_taylor_and_activation_potentials,keras.engine.training.Model) | ||
S3method(plot_taylor_and_activation_potentials,list) | ||
S3method(predict,nn2poly) | ||
export(add_constraints) | ||
export(change_string_to_function) | ||
export(eval_poly) | ||
export(fit) | ||
export(luz_model_sequential) | ||
export(nn2poly) | ||
export(obtain_derivatives_list) | ||
export(plot_diagonal) | ||
export(plot_n_important_coeffs) | ||
export(plot_taylor_and_activation_potentials) | ||
importFrom(Rcpp,sourceCpp) | ||
importFrom(generics,fit) | ||
importFrom(stats,density) | ||
useDynLib(nn2poly, .registration = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
select_allowed_partitions <- function(equivalent_label, q_previous_layer, labels, partitions) { | ||
.Call(`_nn2poly_select_allowed_partitions`, equivalent_label, q_previous_layer, labels, partitions) | ||
} | ||
|
||
alg_non_linear <- function(coeffs_input, labels_input, labels_output, q_taylor_vector, current_layer, g, partitions_labels, partitions) { | ||
.Call(`_nn2poly_alg_non_linear`, coeffs_input, labels_input, labels_output, q_taylor_vector, current_layer, g, partitions_labels, partitions) | ||
} | ||
|
||
combinations_with_repetition <- function(n, k) { | ||
.Call(`_nn2poly_combinations_with_repetition`, n, k) | ||
} | ||
|
||
generate_partitions <- function(p, q_max) { | ||
.Call(`_nn2poly_generate_partitions`, p, q_max) | ||
} | ||
|
||
generate_partitions_full <- function(p, q_max) { | ||
.Call(`_nn2poly_generate_partitions_full`, p, q_max) | ||
} | ||
|
||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
select_allowed_partitions <- function(equivalent_label, q_previous_layer, labels, partitions) { | ||
.Call(`_nn2poly_select_allowed_partitions`, equivalent_label, q_previous_layer, labels, partitions) | ||
} | ||
|
||
alg_non_linear <- function(coeffs_input, labels_input, labels_output, q_taylor_vector, current_layer, g, partitions_labels, partitions) { | ||
.Call(`_nn2poly_alg_non_linear`, coeffs_input, labels_input, labels_output, q_taylor_vector, current_layer, g, partitions_labels, partitions) | ||
} | ||
|
||
combinations_with_repetition <- function(n, k) { | ||
.Call(`_nn2poly_combinations_with_repetition`, n, k) | ||
} | ||
|
||
generate_partitions <- function(p, q_max) { | ||
.Call(`_nn2poly_generate_partitions`, p, q_max) | ||
} | ||
|
||
generate_partitions_full <- function(p, q_max) { | ||
.Call(`_nn2poly_generate_partitions_full`, p, q_max) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Build the appropriate callback based on the model class | ||
#' @noRd | ||
build_callback <- function(object, | ||
type = c("l1_norm", "l2_norm")) { | ||
UseMethod("build_callback") | ||
} | ||
|
||
norm_order <- function(type = c("l1_norm", "l2_norm")) { | ||
as.numeric(substr(match.arg(type), 2, 2)) | ||
} | ||
|
||
build_callback.luz_module_generator <- function(object, | ||
type = c("l1_norm", "l2_norm")) { | ||
luz_callback <- luz::luz_callback( | ||
name = paste0(type, "_callback"), | ||
|
||
initialize = function() { | ||
self$constraint <- torch_constraint(norm_order(type)) | ||
}, | ||
|
||
on_train_batch_end = function() { | ||
for (layer in utils::head(ctx$model$children, -1)) | ||
layer$apply(self$constraint) | ||
} | ||
) | ||
|
||
luz_callback() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#' @importFrom generics fit | ||
#' @export | ||
generics::fit | ||
|
||
#' @export | ||
fit.nn2poly <- function(object, ...) { | ||
callback <- build_callback(object, attr(object, "constraint")) | ||
NextMethod(callbacks = append(as.list(list(...)[["callbacks"]]), callback)) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.