Dense

class Dense(outputSize: Int, activation: Activations, kernelInitializer: Initializer, biasInitializer: Initializer, kernelRegularizer: Regularizer?, biasRegularizer: Regularizer?, activityRegularizer: Regularizer?, useBias: Boolean, name: String) : Layer, TrainableLayer

Densely-connected (fully-connected) layer class.

This layer implements the operation: outputs = activation(inputs * kernel + bias)

where activation is the element-wise activation function passed as the activation argument, kernel is a weights' matrix created by the layer, and bias is a bias vector created by the layer (only applicable if use_bias is True).

Constructors

Dense
Link copied to clipboard
fun Dense(outputSize: Int = 128, activation: Activations = Activations.Relu, kernelInitializer: Initializer = HeNormal(), biasInitializer: Initializer = HeUniform(), kernelRegularizer: Regularizer? = null, biasRegularizer: Regularizer? = null, activityRegularizer: Regularizer? = null, useBias: Boolean = true, name: String = "")

Creates Dense object.

Functions

build
Link copied to clipboard
open override fun build(tf: Ops, inputShape: Shape)

Extend this function to define variables in layer.

buildFromInboundLayers
Link copied to clipboard
fun buildFromInboundLayers(tf: Ops)

Extend this function to define variables in layer.

computeOutputShape
Link copied to clipboard
open override fun computeOutputShape(inputShape: Shape): Shape

Computes output shape, based on inputShape and Layer type.

computeOutputShapeFromInboundLayers
Link copied to clipboard
open fun computeOutputShapeFromInboundLayers(): TensorShape

Computes output shape, based on input shapes of inbound layers.

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

Builds main layer input transformation with tf. Depends on Layer type.

open fun forward(tf: Ops, input: List<Operand<Float>>, isTraining: Operand<Boolean>, numberOfLosses: Operand<Float>?): Operand<Float>

Builds main layer input transformation with tf. Depends on Layer type.

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

activation
Link copied to clipboard
val activation: Activations

Activation function.

activityRegularizer
Link copied to clipboard
val activityRegularizer: Regularizer? = null

Regularizer function applied to the output of the layer (its "activation").

biasInitializer
Link copied to clipboard
val biasInitializer: Initializer

Initializer function for the bias.

biasRegularizer
Link copied to clipboard
val biasRegularizer: Regularizer? = null

Regularizer function applied to the bias vector.

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.

isTrainable
Link copied to clipboard
open override var isTrainable: Boolean = true

True, if layer's weights could be changed during training. If false, layer's weights are frozen and could not be changed during training.

kernelInitializer
Link copied to clipboard
val kernelInitializer: Initializer

Initializer function for the 'kernel' weights matrix.

kernelRegularizer
Link copied to clipboard
val kernelRegularizer: Regularizer? = null

Regularizer function applied to the kernel weights matrix.

name
Link copied to clipboard
var name: String

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

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.

outputSize
Link copied to clipboard
val outputSize: Int = 128

Dimensionality of the output space.

paramCount
Link copied to clipboard
open val paramCount: Int

Number of parameters in this layer.

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

Model where this layer is used.

useBias
Link copied to clipboard
val useBias: Boolean = true

If true the layer uses a bias vector.

variables
Link copied to clipboard
open override val variables: List<KVariable>

Variables used in this layer.