Class HardSigmoid
java.lang.Object
org.tensorflow.framework.activations.AbstractActivation
org.tensorflow.framework.activations.HardSigmoid
- All Implemented Interfaces:
Activation
Hard sigmoid activation.
A faster approximation of the sigmoid activation.
Defined as:
if x < -2.5: return 0if x > 2.5: return 1if -2.5 <= x <= 2.5: return 0.2 * x + 0.5
For example:
Operand<TFloat32> input = tf.constant(
new float[] {-3.0f,-1.0f, 0.0f,1.0f,3.0f});
HardSigmoid<TFloat32> hardSigmoid = new HardSigmoid<>(tf);
Operand<TFloat32> result = hardSigmoid.call(input);
// result is [0.f , 0.3f, 0.5f, 0.7f, 1.f]
-
Field Summary
FieldsFields inherited from class AbstractActivation
NAME_KEY, tf -
Constructor Summary
ConstructorsConstructorDescriptionCreates Hard sigmoid activation.HardSigmoid(Map<String, Object> config) Creates a new Exponential from a configuration Map -
Method Summary
Modifier and TypeMethodDescriptionGets the calculation operation for the activation.Gets a configuration mapgetName()Get the name of the activation as known by the TensorFlow EnginehardSigmoid(Ops tf, Operand<T> input) Computes the hard sigmoid activation function.Methods inherited from class AbstractActivation
checkClassName, checkConfigKeys, getDefaultConfig, getTF, setTF
-
Field Details
-
NAME
-
-
Constructor Details
-
HardSigmoid
public HardSigmoid()Creates Hard sigmoid activation. -
HardSigmoid
Creates a new Exponential from a configuration Map- Parameters:
config- the configuration map, this class does not use any of the entries in the configuration map- 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
-
hardSigmoid
Computes the hard sigmoid activation function.Example Usage:
Operand<TFloat32> input = ...; Operand<TFloat32> result = HardSigmoid.hardSigmoid(tf, input);- Type Parameters:
T- the data type for the input- Parameters:
tf- the TensorFlow Opsinput- the input- Returns:
- the exponential activation:
exp(x).
-
getConfig
Gets a configuration map- Specified by:
getConfigin classAbstractActivation- Returns:
- 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
-