softmax: Number Softmax

Description Usage Arguments Value Author(s) Examples

Description

Calculates the Softmax function

sofmax = \frac{exp(\bf x)}{∑{exp(\bf x)}}

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'modello_number'
softmax(x, k = 0)

## S3 method for class 'numeric'
softmax(x, k = 0)

## S3 method for class 'matrix'
softmax(x, k = 0)

softmax(x, k)

Arguments

x

a 'numeric' or a reference object of class 'number'

k

dimension index. Currently constained to be <= 2

Value

Returns a 'numeric' or reference object of class 'number'

Author(s)

Filippo Monari

Examples

 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
modello.init(10, 10, 10, 10)
## For modello_number matrices
x = number(matrix(rnorm(9), 3, 3))
y1 = softmax(x)
print(y1)
print(y1$v)
y2 = softmax(x, 1)
print(y2)
print(y2$v)
y3 = softmax(x, 2)
print(y3)
print(y3$v)
modello.close()
## For numerics
x = rnorm(5)
y = softmax(x)
print(y)
## For matrices
x = matrix(rnorm(9), 3, 3)
y1 = softmax(x)
print(y1)
y2 = softmax(x, 1)
print(y2)
y3 = softmax(x, 2)
print(y3)

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

Related to softmax in modello...