MnistCnn

Constructs a Convolutional Neural Network (CNN) tailored for the MNIST dataset using a DSL-based network builder.

This model consists of two convolutional blocks followed by a flattening stage and two dense (fully connected) layers. It is designed to classify handwritten digits (0–9) from grayscale 28x28 pixel images.

The architecture is as follows:

  • Stage: "conv1"

  • 2D Convolution with:

    • 16 output channels

    • 5x5 kernel

    • stride of 1

    • padding of 2

  • ReLU activation

  • 2x2 MaxPooling with stride of 2

  • Stage: "conv2"

  • 2D Convolution with:

    • 32 output channels

    • 5x5 kernel

    • stride of 1

    • padding of 2

  • ReLU activation

  • 2x2 MaxPooling with stride of 2

  • Stage: "flatten"

  • Flattens the tensor for dense layer input

  • Stage: "dense"

  • Fully connected layer with 128 units

  • ReLU activation

  • Stage: "output"

  • Fully connected layer with 10 output units (for 10 MNIST classes)

  • Softmax activation over dimension 1 to produce class probabilities

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open suspend override fun calculate(module: Module<FP32, Float>, inputValue: Tensor<FP32, Float>, executionContext: ExecutionContext, reportProgress: suspend (current: Int, total: Int, message: String?) -> Unit): Tensor<FP32, Float>

Implement this in your models. Call reportProgress whenever you want to emit a progress update.

Link copied to clipboard
open override fun create(executionContext: ExecutionContext): Module<FP32, Float>
Link copied to clipboard
fun model(executionContext: ExecutionContext): Module<FP32, Float>
Link copied to clipboard
open override fun modelCard(): ModelCard