To run the tests, use cargo test.
To run the examples, use:
cargo run --example <example_name> --features "test-types"
where <example_name> is one of the following:
simple_perceptron_mnist_inferencesimple_perceptron_mnist_prooftwo_layer_perceptron_mnist_inferencetwo_layer_perceptron_mnist_proof
In order to run any tests involving python code, such as compatibility tests with TF Lite, the feature python must be activated (which automatically enables test-types).
In order to save a numpy ndarray (python side) as a serialised JSON which can be directly read into a QArray of ours (Rust side),
- Convert the
ndarrayinto anOrderedDictusing our custom python functiontensor_to_dict(available in several of the python notebooks) - Pass the resulting
OrderedDicttogether with the destination path tojson.dump.
The saved JSON file can be deserialised over in Rust with QArray::read(path: &str) -> QArray. If instead of a single OrderedDict, a python list of OrderedDicts is passed to json.dump, the resulting file can be deserialised with QArray::read_list(path: &str) -> Vec<QArray> .
Cf. exploring_tf_lite/training_two_layer_perceptron.ipynb for example usage.
This can be useful when bringing over to Rust some TF Lite model parameters or inputs.