ReLU

class ReLU(maxValue: Float?, negativeSlope: Float, threshold: Float, name: String) : AbstractActivationLayer

Rectified Linear Unit activation function.

With default values, it returns element-wise max(x, 0).

Otherwise, it follows:

f(x) = maxValue,                        if x >= maxValue
f(x) = x, if threshold <= x < maxValue
f(x) = negativeSlope * (x - threshold), if x < threshold

Since

0.2

Constructors

ReLU
Link copied to clipboard
fun ReLU(maxValue: Float? = null, negativeSlope: Float = 0.0f, threshold: Float = 0.0f, name: String = "")

Creates ReLU object.

Functions

build
Link copied to clipboard
open override fun build(tf: Ops, input: Operand<Float>, isTraining: Operand<Boolean>, numberOfLosses: Operand<Float>?): Operand<Float>
open fun build(tf: Ops, input: List<Operand<Float>>, isTraining: Operand<Boolean>, numberOfLosses: Operand<Float>?): Operand<Float>

Extend this function to define variables in the layer and compute layer output.

forward
Link copied to clipboard
open override fun forward(tf: Ops, input: Operand<Float>): Operand<Float>

Applies the activation functions to the input to produce the output.

invoke
Link copied to clipboard
operator fun invoke(vararg layers: Layer): Layer

Important part of functional API. It takes layers as input and saves them to the inboundLayers of the given layer.

toString
Link copied to clipboard
open override fun toString(): String

Properties

hasActivation
Link copied to clipboard
open override val hasActivation: Boolean

Returns True, if layer has internal activation function.

inboundLayers
Link copied to clipboard
var inboundLayers: MutableList<Layer>

Returns inbound layers.

maxValue
Link copied to clipboard
val maxValue: Float? = null

Maximum activation value. Should be >= 0.

name
Link copied to clipboard
var name: String

Layer name. A new name is generated during model compilation when provided name is empty.

negativeSlope
Link copied to clipboard
val negativeSlope: Float = 0.0f

Negative slope coefficient. Should be >= 0.

outboundLayers
Link copied to clipboard
var outboundLayers: MutableList<Layer>

Returns outbound layers.

outputShape
Link copied to clipboard
lateinit var outputShape: TensorShape

Output data tensor shape.

parentModel
Link copied to clipboard
var parentModel: GraphTrainableModel? = null

Model where this layer is used.

threshold
Link copied to clipboard
val threshold: Float = 0.0f

Threshold value for threshold activation.