Layer

abstract class Layer(name: String)

Base abstract class for all layers.

Constructors

Layer
Link copied to clipboard
fun Layer(name: String)

Functions

build
Link copied to clipboard
abstract 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
abstract 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 fun forward(tf: Ops, input: List<Operand<Float>>, isTraining: Operand<Boolean>, numberOfLosses: Operand<Float>?): Operand<Float>
abstract 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.

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.

Properties

hasActivation
Link copied to clipboard
abstract val hasActivation: Boolean

Returns True, if layer has internal activation function.

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

Returns inbound layers.

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.

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

Model where this layer is used.

Inheritors

AbstractActivationLayer
Link copied to clipboard
AbstractConv
Link copied to clipboard
SeparableConv2D
Link copied to clipboard
Dense
Link copied to clipboard
Input
Link copied to clipboard
AbstractMerge
Link copied to clipboard
BatchNorm
Link copied to clipboard
AvgPool1D
Link copied to clipboard
AvgPool2D
Link copied to clipboard
AvgPool3D
Link copied to clipboard
GlobalAvgPool1D
Link copied to clipboard
GlobalAvgPool2D
Link copied to clipboard
GlobalAvgPool3D
Link copied to clipboard
GlobalMaxPool1D
Link copied to clipboard
GlobalMaxPool2D
Link copied to clipboard
GlobalMaxPool3D
Link copied to clipboard
MaxPool1D
Link copied to clipboard
MaxPool2D
Link copied to clipboard
MaxPool3D
Link copied to clipboard
Dropout
Link copied to clipboard
AbstractCropping
Link copied to clipboard
AbstractUpSampling
Link copied to clipboard
AbstractZeroPadding
Link copied to clipboard
Flatten
Link copied to clipboard
Permute
Link copied to clipboard
RepeatVector
Link copied to clipboard
Reshape
Link copied to clipboard

Extensions

freeze
Link copied to clipboard
fun Layer.freeze()

Freezes layer weights, so they won't be changed during training.

isTrainable
Link copied to clipboard
val Layer.isTrainable: Boolean

Returns true if this Layer is trainable, false otherwise. Always returns false for layers not implementing TrainableLayer.

paramCount
Link copied to clipboard
val Layer.paramCount: Int

Returns the number of parameters in this layer. If layer is not a ParametrizedLayer, returns zero.

unfreeze
Link copied to clipboard
fun Layer.unfreeze()

Unfreezes layer weights, allowing to change them during training.

weights
Link copied to clipboard
var Layer.weights: Map<String, Array<*>>

Weights of this layer. Require parent model to be set on the layer.