module.softmax: R6 class representing a softmax regression model.

Description Super classes Methods Author(s) Examples

Description

R6 class representing a softmax regression model.

R6 class representing a softmax regression model.

Super classes

modello::module -> modello::module.lm -> module.softmax

Methods

Public methods

Inherited methods

Method 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 = softmax(W.op(X) + B)

Usage
module.softmax$new(tx, nin, nout, b = TRUE)
Arguments
tx

if TRUE it traspose the input matrix

nin

number of column of the input matrix

nout

number of outputs

b

if TRUE the intercept term is included

Returns

Returns the total number of parameters


Method op()

Performs: ans = sigmoid(W.op(X) + B)

Usage
module.softmax$op(X)
Arguments
X

input matrix, reference object of class 'number'

Returns

Returns a reference object of class 'number'

Examples
\donttest{
modello.init(10, 10, 10, 10)
X = number(matrix(rnorm(12), 6), dx=FALSE)
mdl = module.softmax$new(1, 2, 3, b=FALSE)
print(X$v)
Yh = mdl$op(X)
print(Yh)
print(Yh$v)
modello.close()
}

Method clone()

The objects of this class are cloneable with this method.

Usage
module.softmax$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Author(s)

Filippo Monari

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## ------------------------------------------------
## Method `module.softmax$op`
## ------------------------------------------------


modello.init(10, 10, 10, 10)
X = number(matrix(rnorm(12), 6), dx=FALSE)
mdl = module.softmax$new(1, 2, 3, b=FALSE)
print(X$v)
Yh = mdl$op(X)
print(Yh)
print(Yh$v)
modello.close()

modello documentation built on Feb. 2, 2021, 9:06 a.m.