mojolearn.MLPInference#
- class mojolearn.MLPInference(weight1, bias1, weight2, bias2)[source]#
Bases:
objectForward-only
SmallMLPTrainernetwork (8 -> 16 ReLU -> 3, float32) on the CPU.Computes the same logits as
SmallMLPTrainer.predict_logitsfrom the same weights. The weights are copied at construction and never change; the weight matrices may also be given packed bymojolearn.lowbit, in which case they are unpacked exactly to float32. Each row’s logits depend on that row alone.- Parameters:
weight1 (array of float32) – First-layer weights.
bias1 (array of float32) – First-layer bias.
weight2 (array of float32) – Second-layer weights.
bias2 (array of float32) – Second-layer bias.
- Variables:
weight_format (str) – Format the weight matrices were given in: “float32”, or the packed
mojolearn.lowbitformat.
Examples
>>> import mojolearn >>> model = mojolearn.MLPInference.from_checkpoint("mlp.ckpt") >>> logits = model.predict_logits(X) # X: (rows, 8) float32, 1..256 rows
Methods
from_checkpoint(path)Build from a
SmallMLPTrainer.save_checkpointfile.Logits for
X.Attributes
An independent copy of the four weights, keyed by name.
- classmethod from_checkpoint(path)[source]#
Build from a
SmallMLPTrainer.save_checkpointfile.The file’s size, schema, SHA-256 and arithmetic profile are checked (any mismatch raises
ValueError); the optimizer state is validated and dropped.- Parameters:
path (str or path-like) – Checkpoint file.
- Returns:
MLPInference
- property weights_#
An independent copy of the four weights, keyed by name.