Description Super class Methods Author(s) Examples
R6 class representing a linear model.
R6 class representing a linear model.
modello::module -> module.lm
new()The initialisation method sets the weights (W), the bais (B) matrices, the objective function (obj), as well as the name of the module. The calculation performed is the following ans = W.op(X) + B
module.lm$new(tx, nin, nout, obj = mse, b = TRUE)
txif TRUE it traspose the input matrix
ninnumber of column of the input matrix
noutnumber of outputs
objobjective function to adopt
bif TRUE the intercept term is included
Returns the total number of parameters
op()Performs: ans = W.op(X) + B
module.lm$op(X)
Xinput matrix, reference object of class 'number'
Returns a reference object of class 'number'
\donttest{
modello.init(10, 10, 10, 10)
X = number(as.matrix(rnorm(10)), dx=FALSE)
mdl = module.lm$new(1, 1, 1, b=FALSE)
print(X$v)
Yh = mdl$op(X)
print(Yh)
print(Yh$v)
modello.close()
}
obj()Calculates the objective function.
module.lm$obj(y, X)
ytarget values, reference object of class 'number'
Xinput matrix, reference object of class 'number'
Returns a reference object of class 'number'
\donttest{
modello.init(10, 10, 10, 10)
X = number(as.matrix(rnorm(10)), dx=FALSE)
y = number(as.matrix(rnorm(10)), dx=FALSE)
mdl = module.lm$new(1, 1, 1, b=FALSE)
g = graph.open()
J = mdl$obj(y, X)
graph.close()
J$dv = 1
g$bw()
print(lapply(mdl$pars(), function(x)x$dv))
modello.close()
}
pars()Returns the parameters of the module as list with entries: W = weight matrix, and B = bias matrix
module.lm$pars()
Returns a flat list with the parametrs of the module
\donttest{
modello.init(10, 10, 10, 10)
mdl = module.lm$new(1, 1, 1, b=FALSE)
print(mdl$pars())
print(lapply(mdl$pars(), function(x)x$v))
print(lapply(mdl$pars(), function(x)x$dv))
modello.close()
}
clone()The objects of this class are cloneable with this method.
module.lm$clone(deep = FALSE)
deepWhether to make a deep clone.
Filippo Monari
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ## ------------------------------------------------
## Method `module.lm$op`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
X = number(as.matrix(rnorm(10)), dx=FALSE)
mdl = module.lm$new(1, 1, 1, b=FALSE)
print(X$v)
Yh = mdl$op(X)
print(Yh)
print(Yh$v)
modello.close()
## ------------------------------------------------
## Method `module.lm$obj`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
X = number(as.matrix(rnorm(10)), dx=FALSE)
y = number(as.matrix(rnorm(10)), dx=FALSE)
mdl = module.lm$new(1, 1, 1, b=FALSE)
g = graph.open()
J = mdl$obj(y, X)
graph.close()
J$dv = 1
g$bw()
print(lapply(mdl$pars(), function(x)x$dv))
modello.close()
## ------------------------------------------------
## Method `module.lm$pars`
## ------------------------------------------------
modello.init(10, 10, 10, 10)
mdl = module.lm$new(1, 1, 1, b=FALSE)
print(mdl$pars())
print(lapply(mdl$pars(), function(x)x$v))
print(lapply(mdl$pars(), function(x)x$dv))
modello.close()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.