SequentialModelBuilder

class SequentialModelBuilder @JvmOverloads constructor(ctx: ExecutionContext, dtype: DType = FP32)(source)

Java-friendly sequential model builder that mirrors the Kotlin DSL.

Example usage from Java:

Module model = new SequentialModelBuilder(ctx)
.input(784)
.dense(128)
.relu()
.dense(10)
.build();

Parameters

ctx

The execution context used for weight initialization.

dtype

The data type for the model. Defaults to FP32.

Constructors

Link copied to clipboard
constructor(ctx: ExecutionContext, dtype: DType = FP32)

Functions

Link copied to clipboard
fun build(): Module<DType, Any?>

Builds and returns the sequential model.

Link copied to clipboard
fun dense(outputSize: Int): SequentialModelBuilder

Adds a dense (fully connected) layer.

Link copied to clipboard
fun flatten(startDim: Int = 1, endDim: Int = -1): SequentialModelBuilder

Adds a Flatten layer.

Link copied to clipboard

Adds a GELU activation.

Link copied to clipboard

Sets the input size for the network. Must be called first.

Link copied to clipboard

Adds a ReLU activation.

Link copied to clipboard

Adds a Sigmoid activation.

Link copied to clipboard

Adds a SiLU (Swish) activation.

Link copied to clipboard

Adds a Softmax activation along the given dimension.