Class Softmax
- All Implemented Interfaces:
Activation
The elements of the output vector are in range (0, 1) and sum to 1.
Each vector is handled independently. The axis argument sets which axis of the input
the function is applied along.
Softmax is often used as the activation for the last layer of a classification network because the result could be interpreted as a probability distribution.
The softmax of each vector x is computed as: exp(x) / tf.sum(exp(x)).
The input values in are the log-odds of the resulting probability.
-
Field Summary
FieldsFields inherited from class AbstractActivation
NAME_KEY, tf -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the calculation operation for the activation.intgetAxis()Gets the axis along which the softmax normalization is applied.Gets a configuration map with entriesaxisand value set withaxis.getName()Get the name of the activation as known by the TensorFlow EngineConverts a vector of values to a probability distribution along the last axis.Converts a vector of values to a probability distribution.Methods inherited from class AbstractActivation
checkClassName, checkConfigKeys, getDefaultConfig, getTF, setTF
-
Field Details
-
NAME
-
-
Constructor Details
-
Softmax
public Softmax()Creates a softmax activation where the default axis isAXIS_DEFAULTwhich indicates the last dimension. -
Softmax
public Softmax(int axis) Creates a Softmax activation- Parameters:
axis- The dimension softmax would be performed on.
-
Softmax
Creates a Softmax activation from a config map.- Parameters:
config- the configuration map, if the map contains an entry foraxisthat value is used, otherwiseAXIS_DEFAULTis used.- Throws:
IllegalArgumentException- if the configuration contains unsupported keys for this class or if the value for the name key does not match the name for the Activation
-
-
Method Details
-
softmax
Converts a vector of values to a probability distribution along the last axis.The elements of the output vector are in range (0, 1) and sum to 1.
Each vector is handled independently. The
axisargument sets which axis of the input the function is applied along.Softmax is often used as the activation for the last layer of a classification network because the result could be interpreted as a probability distribution.
The softmax of each vector x is computed as
exp(x) / tf.reduce_sum(exp(x)). The input values in are the log-odds of the resulting probability.- Type Parameters:
T- teh data type of the input- Parameters:
tf- the TensorFlow Opsinput- the input- Returns:
- the output of softmax transformation (all values are non-negative and sum to 1).
-
softmax
public static <T extends TNumber> Operand<T> softmax(Ops tf, Operand<T> input, Operand<TInt32> axis) Converts a vector of values to a probability distribution.The elements of the output vector are in range (0, 1) and sum to 1.
Each vector is handled independently. The
axisargument sets which axis of the input the function is applied along.Softmax is often used as the activation for the last layer of a classification network because the result could be interpreted as a probability distribution.
The softmax of each vector x is computed as
exp(x) / tf.reduce_sum(exp(x)). The input values in are the log-odds of the resulting probability.- Type Parameters:
T- teh data type of the input- Parameters:
tf- the TensorFlow Opsinput- the inputaxis- Integer, axis along which the softmax normalization is applied.- Returns:
- the output of softmax transformation (all values are non-negative and sum to 1).
-
getConfig
Gets a configuration map with entriesaxisand value set withaxis.
- Specified by:
getConfigin classAbstractActivation- Returns:
- config the configuration map
-
call
-
getName
Get the name of the activation as known by the TensorFlow Engine- Specified by:
getNamein classAbstractActivation- Returns:
- the name of the activation as known by the TensorFlow Engine
-
getAxis
public int getAxis()Gets the axis along which the softmax normalization is applied.- Returns:
- the axis along which the softmax normalization is applied.
-