af.softmax: An Activation Function: Softmax

View source: R/af.softmax.R

af.softmaxR Documentation

An Activation Function: Softmax

Description

This function computes the softmax of a numeric vector. The softmax function transforms a vector of real values into a probability distribution, where each element is between 0 and 1 and the sum of all elements is 1. @seealso DNN_predictor

Usage

af.softmax(x)

Arguments

x

A numeric vector for which the softmax transformation is to be computed.

Details

The softmax function is calculated as:

softmax(x_i) = \frac{exp(x_i)}{\sum_{j} exp(x_j)}

In the case of overflow (i.e., when exp(x_i) is too large), this function handles Inf values by assigning 1 to the corresponding positions and 0 to the others before Softmax. @seealso DNN_predictor

Value

A numeric vector representing the softmax-transformed values of x.

Examples

x <- c(1, 2, 3)
af.softmax(x)


EFAfactors documentation built on Sept. 30, 2024, 1:06 a.m.