Skip to contents

Forward propagation, analytic back-propagation gradients and gradient-descent training for a feed-forward network.

Usage

morie_ann_forward(X, W, activations = NULL) 

morie_ann_gradients(X, y, W, activations = NULL) 

morie_ann_train(X, y, W, eta = 0.1, n_iter = 500L, activations = NULL, tol = 1e-12)

Arguments

X

numeric matrix of inputs, one row per observation

y

numeric response vector or matrix

W

list of weight matrices, one per layer

activations

character vector of activation names, one per layer

eta

learning rate

n_iter

number of gradient-descent steps

tol

argument tol; not described in the source.

Value

A list holding the fitted quantities for the method called: point estimates, fitted values and any diagnostics it produces. See the individual method descriptions above for the components each returns.

Details

These functions mirror, in R, the implementations in the Python package morie; the two are checked against each other by the parity tests in tests/testthat/.

Examples

set.seed(1)
X <- matrix(rnorm(20), 10, 2)
W <- list(matrix(rnorm(6, 0, 0.4), 3, 2), matrix(rnorm(3, 0, 0.4), 1, 3))
r <- morie_ann_forward(X, W)
str(r, max.level = 1)
#> List of 4
#>  $ output     : num [1:10, 1] -0.425 -0.44 -0.363 -0.444 -0.464 ...
#>  $ layers     :List of 3
#>  $ nets       :List of 2
#>  $ activations: chr [1:2] "logistic" "identity"