A package that provides advanced coding tools for training and deploying AI
Project description
instmodel
instmodel is a Python package designed to simplify the creation of instruction-based neural network models using a Keras backend. With instmodel, you can quickly build, train, and export your models into a compact “instruction” format suitable for lightweight inference, serialization, or deployment.
Features
- High-Level Model Building: Easily construct neural networks using familiar Keras-like layers such as
Dense,Attention, and more. - Instruction Model Export: Convert your trained models into a JSON-based “instruction model” that precisely reflects the network architecture, weights, and activations.
- Validation & Debugging: Verify that the instruction model produces the same outputs as the original Keras model with built-in validation functions.
- Easy Deployment: Use the exported instruction model for lightweight or custom inference scenarios (e.g., embedded systems).
Installation
Install the latest release from PyPI:
pip install instmodel
Quick Example
Below is a simplified example (adapted from the test suite) showing how to:
- Define a feed-forward network using Keras-like syntax.
- Train it on dummy data.
- Export it as an instruction model.
- Validate it against the original Keras model outputs.
import numpy as np
from instmodel.model import (
Dense,
InputBuffer,
ModelGraph,
ff_model,
validate_keras_model
)
from instmodel.instruction_model import validate_instruction_model
# 1. Define a simple feed-forward model (three Dense layers).
input_buffer = InputBuffer(4, name="simple_input")
hidden = Dense(8, activation="relu", name="hidden_relu_1")(input_buffer)
hidden = Dense(6, activation="relu", name="hidden_relu_2")(hidden)
output = Dense(1, activation="sigmoid", name="output_sigmoid")(hidden)
model_graph = ModelGraph(input_buffer, output)
model_graph.compile(optimizer="adam", loss="binary_crossentropy")
# 2. Train the model on dummy data.
x_data = np.random.random((10, 4))
y_data = np.random.randint(0, 2, size=(10, 1))
model_graph.fit(x_data, y_data, epochs=1, verbose=0)
# 3. Export the trained Keras model to an instruction model.
instruction_model = model_graph.create_instruction_model()
# 4. Validate the exported instruction model against the original Keras outputs.
keras_pred = model_graph.predict(x_data, verbose=0)
instruction_model["validation_data"] = {
"inputs": x_data.tolist(),
"expected_outputs": keras_pred.tolist(),
}
validate_instruction_model(instruction_model) # Check instruction-model output
validate_keras_model(model_graph.get_keras(), instruction_model["validation_data"]) # Compare with Keras model
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instmodel-0.2.0.tar.gz.
File metadata
- Download URL: instmodel-0.2.0.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
914f5c178a832730c683fe890f87a614cb6d066c9440f8c8e4cf1ef7e51fca41
|
|
| MD5 |
8e56cddf775ba23092ad6848ec3d793c
|
|
| BLAKE2b-256 |
908157f1cc15b12405251e5048a688074c1703175183a047850e055b57cb665e
|
Provenance
The following attestation bundles were made for instmodel-0.2.0.tar.gz:
Publisher:
pypi-publish.yml on Joaoprcf/instmodel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instmodel-0.2.0.tar.gz -
Subject digest:
914f5c178a832730c683fe890f87a614cb6d066c9440f8c8e4cf1ef7e51fca41 - Sigstore transparency entry: 205154805
- Sigstore integration time:
-
Permalink:
Joaoprcf/instmodel@a52ea26cf85648326aae86537e773717fe2fe1bf -
Branch / Tag:
refs/tags/release-0.2.0 - Owner: https://github.com/Joaoprcf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a52ea26cf85648326aae86537e773717fe2fe1bf -
Trigger Event:
push
-
Statement type:
File details
Details for the file instmodel-0.2.0-py3-none-any.whl.
File metadata
- Download URL: instmodel-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96fce1c869f2d816ddd0cb44e5364d34bd9009331c4b8ba3d76d11b0e9b1662b
|
|
| MD5 |
cd653b79da06f419ccfb22eb7ccc2c7f
|
|
| BLAKE2b-256 |
3a28e3c3dfff1376f21408e1188cb71a0b1c05f815178f53d2ec40c3dd67afe1
|
Provenance
The following attestation bundles were made for instmodel-0.2.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on Joaoprcf/instmodel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
instmodel-0.2.0-py3-none-any.whl -
Subject digest:
96fce1c869f2d816ddd0cb44e5364d34bd9009331c4b8ba3d76d11b0e9b1662b - Sigstore transparency entry: 205154808
- Sigstore integration time:
-
Permalink:
Joaoprcf/instmodel@a52ea26cf85648326aae86537e773717fe2fe1bf -
Branch / Tag:
refs/tags/release-0.2.0 - Owner: https://github.com/Joaoprcf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@a52ea26cf85648326aae86537e773717fe2fe1bf -
Trigger Event:
push
-
Statement type: