Learn R Programming

EFAfactors (version 1.2.2)

af.softmax: 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)

Value

A numeric vector representing the softmax-transformed values of 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

Examples

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

Run the code above in your browser using DataLab