micropyML

micropyML is a lightweight embedded machine-learning utility module for MicroPython, built on top of ulab.numpy.ndarray. It provides common neural-network operations optimized for microcontrollers and resource-constrained environments.

micropyML functions:

Function Overview

Activations

relu(x)
Rectified Linear Unit activation, element-wise.

reluN(x, N=6)
ReLU activation with configurable upper bound. ReLU6 is widely used.

softmax(x)
Fixed-point softmax for integer input arrays.

confidence(x)
Convert fixed-point softmax output to percent confidence.

Layers

dropout(x, p=0.5)
Apply dropout regularization.

maxpool1d(x, k=2)
1D max pooling over a 3D input tensor.

conv1d(x, kernel, bias=0)
Floating-point 1D convolution layer.

qconvrelu1d(x, kernel, bias=0, quant_params=(1, 0, 0))
Quantized 1D convolution with ReLU activation fused in.

Function Documentation

Activations

Relu

micropyML.relu(x)

Apply the ReLU (Rectified Linear Unit) activation function element-wise.

Parameters
Returns

reluN

micropyML.reluN(x, N=6)

Apply a clipped ReLU activation function element-wise, where the output is limited to an upper bound N. ReLU6 is most commonly used in mobile and edge applications. The upper bound of 6 is based on tests performed in Convolutional Deep Belief Networks on CIFAR-10.

Parameters
Returns

Softmax

micropyML.softmax(x)

Compute the softmax activation for integer-valued input arrays.

Parameters
Returns
Notes

Confidence

micropyML.confidence(x)

Convert fixed-point softmax output into confidence values suitable for display.

Parameters
Returns

Layers

Dropout

micropyML.dropout(x, p=0.5)

Apply dropout regularization to an input array.

Parameters
Returns

Maxpool1d

micropyML.maxpool1d(x, k=2)

Perform 1D max pooling over a 3D input tensor.

Parameters
Returns

Conv1d

micropyML.conv1d(x, kernel, bias=0)

Perform a floating-point 1D convolution, meaning all inputs must be float. Function doesn't cast automatically. Stride and dilation are 1, and padding is 'same' for this implementation.

Parameters
Returns

Quantized Fused ConvRelu1d

micropyML.qconvrelu1d(x, kernel, bias=0, quant_params=(1, 0, 0))

Quantized 1D convolution with fused ReLU activation for integer-only inference. Stride and dilation are 1, and padding is 'same' for this implementation.

Parameters
Returns
Notes