How kvernet/cml works
Main Components and Their Roles
a. Core Library Modules:
• cml_matrix: Implements matrix operations (allocation, inversion, multiplication, etc.), as seen in both src/cml_matrix.c and examples/matrix.
• cml_layer & cml_activation: Handle neural network layers and activations (ReLU, Sigmoid, Softmax, etc.) – with corresponding code in src/cml_layer.c, include/cml_activation.h, and examples/layer.
• cml_loss: Manages loss functions (MSE, Softmax Cross-Entropy) used during training.
• cml_optimizer: Contains the gradient descent algorithm (with plans for additional optimizers like ADAM).
• cml_data: Responsible for dataset management and possibly preprocessing (as indicated by the presence of various datasets in the data directory).
• cml_algorithm & cml_sequential: Likely coordinates the overall network training process, structuring the sequential model.
• cml_prng: Provides pseudo-random number generation for operations such as weight initialization (with supporting examples in the prng directory).
b. Examples & Scripts:
• The examples directory contains runnable C files for demonstrating specific functionalities:
• “layer”: Example implementations of different layers/activations.
• “matrix”: Demonstrates matrix-related computations.
• “sequential”: Provides end-to-end examples for training on different datasets.
• “prng”: Contains tests for randomness functions.
• The scripts directory holds Python wrappers or test scripts that parallel the C examples, which can be used to compare the CML library’s results with TensorFlow.
c. Data Directories:
• The “data” folder stores datasets required for training and testing the library (Iris, Heart Disease, Wine Quality, Lattice-Physics, etc.).
• The “examples/data” folder may include auxiliary data or demonstration-specific datasets.
Relationships and Interactions
• The core library functions (in src and include directories) are used by the example applications.
• For a typical neural network run, data flows from the Data module (cml_data) into the Sequential model (cml_sequential) that uses Layers (cml_layer), Activations (cml_activation), and Matrix Operations (cml_matrix) to perform feed-forward computations.
• The Optimizer (cml_optimizer) and Loss functions (cml_loss) compute error gradients and update weights accordingly.
• The PRNG module helps initialize the parameters in a reproducible (or at least statistically sound) fashion.
• Python scripts (in the scripts directory) interface with the underlying functionalities to compare results, likely orchestrating data preprocessing or comparing performance against TensorFlow.
Architectural Patterns & Technologies
• The project follows a modular design where each mathematical or logical concern (matrix ops, activations, optimizers, etc.) is isolated into its own module.
• It uses a “sequential” architecture that mirrors many deep learning frameworks, where layers are stacked sequentially.
• A Makefile is used for building both the core library and the examples, indicating a compile-time configured build process.
• The structure supports separation of core library functionality (in src and include) from experimental/demonstrative use cases (in examples and scripts).