NeuralNetworkDslImpl

class NeuralNetworkDslImpl<T : DType, V>(val executionContext: ExecutionContext, kClass: KClass<T>) : NeuralNetworkDsl<T, V> (source)

Constructors

Link copied to clipboard
constructor(executionContext: ExecutionContext, kClass: KClass<T>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun activation(id: String, activation: (Tensor<T, V>) -> Tensor<T, V>)

Applies an activation function as a separate layer.

Link copied to clipboard
open override fun avgPool2d(kernelSize: Pair<Int, Int>, stride: Pair<Int, Int>, padding: Pair<Int, Int>, countIncludePad: Boolean, id: String)

Creates a 2D average pooling layer for downsampling feature maps.

Link copied to clipboard
open override fun batchNorm(numFeatures: Int, eps: Double, momentum: Double, affine: Boolean, id: String)

Creates a batch normalization layer for training stability and performance. Normalizes the input across the batch dimension.

Link copied to clipboard
open override fun conv1d(outChannels: Int, kernelSize: Int, stride: Int, padding: Int, dilation: Int, groups: Int, bias: Boolean, id: String, content: CONV1D<T, V>.() -> Unit)

Creates a 1D convolutional layer for processing sequence data.

Link copied to clipboard
open override fun conv2d(id: String, content: CONV2D<T, V>.() -> Unit)

Creates a 2D convolutional layer with all parameters configured inside the DSL block. Example: conv2d("conv1") { outChannels = 16 kernelSize(5) stride(1) padding(2) }

open override fun conv2d(outChannels: Int, kernelSize: Pair<Int, Int>, stride: Pair<Int, Int>, padding: Pair<Int, Int>, dilation: Pair<Int, Int>, groups: Int, bias: Boolean, id: String, content: CONV2D<T, V>.() -> Unit)

Creates a 2D convolutional layer for processing spatial data like images.

Link copied to clipboard
open override fun conv3d(outChannels: Int, kernelSize: Triple<Int, Int, Int>, stride: Triple<Int, Int, Int>, padding: Triple<Int, Int, Int>, dilation: Triple<Int, Int, Int>, groups: Int, bias: Boolean, id: String, content: CONV3D<T, V>.() -> Unit)

Creates a 3D convolutional layer for processing volumetric data.

Link copied to clipboard
fun create(): Module<T, V>
Link copied to clipboard
open override fun dense(id: String, content: DENSE<T, V>.() -> Unit)

Creates a dense layer without specifying output dimension (must be set in content block).

open override fun <TLayer : DType> dense(id: String, content: DENSE<TLayer, V>.() -> Unit): Module<T, V>

Creates a dense layer with precision override without specifying output dimension.

open override fun dense(outputDimension: Int, id: String, content: DENSE<T, V>.() -> Unit)

Creates a dense (fully connected) layer with specified output dimension.

open override fun <TLayer : DType> dense(outputDimension: Int, id: String, content: DENSE<TLayer, V>.() -> Unit): Module<T, V>

Creates a dense layer with precision override and specified output dimension. This allows individual layers to use different precision than the network default.

Link copied to clipboard
open override fun flatten(id: String, content: FLATTEN<T, V>.() -> Unit)

Creates a flatten layer that reshapes multidimensional tensors into 1D. Useful for transitioning from convolutional to dense layers.

Link copied to clipboard
open override fun groupNorm(numGroups: Int, numChannels: Int, eps: Double, affine: Boolean, id: String)

Creates a group normalization layer - alternative normalization approach. Normalizes the input by dividing channels into groups and normalizing within each group.

Link copied to clipboard
open override fun input(inputSize: Int, id: String, requiresGrad: Boolean)

Creates an input layer that defines the entry point for data into the network.

Link copied to clipboard
open override fun layerNorm(normalizedShape: IntArray, eps: Double, elementwiseAffine: Boolean, id: String)

Creates a layer normalization layer - used in attention mechanisms. Normalizes the input across the last dimension(s).

Link copied to clipboard
open override fun maxPool2d(id: String, content: MAXPOOL2D<T, V>.() -> Unit)

Creates a 2D max pooling layer with all parameters configured inside the DSL block. Example: maxPool2d("pool1") { kernelSize(2) stride(2) padding(0) }

open override fun maxPool2d(kernelSize: Pair<Int, Int>, stride: Pair<Int, Int>, padding: Pair<Int, Int>, id: String)

Creates a 2D max pooling layer for downsampling feature maps.

Link copied to clipboard
open override fun sequential(content: NeuralNetworkDsl<T, V>.() -> Unit)

Groups layers into a sequential block for better organization.

Link copied to clipboard
open override fun softmax(dim: Int, id: String)

Applies a Softmax activation as a separate layer.

Link copied to clipboard
open override fun stage(id: String, content: NeuralNetworkDsl<T, V>.() -> Unit)

Creates a named stage/block within the network for modular design.

open override fun <TStage : DType> stage(id: String, content: NeuralNetworkDsl<TStage, V>.() -> Unit): Module<T, V>

Creates a precision-scoped stage within the network. This allows grouping layers with a specific precision type that differs from the network default, enabling fine-grained mixed-precision control.

Link copied to clipboard
open override fun upsample2d(id: String, content: UPSAMPLE2D<T, V>.() -> Unit)

Creates a 2D upsampling layer with parameters configured in the DSL block.

open override fun upsample2d(scale: Pair<Int, Int>, mode: UpsampleMode, alignCorners: Boolean, id: String)

Creates a 2D upsampling layer for increasing spatial resolution.