Skip to content

Conversation

@DLaneAtElekta
Copy link
Owner

Implements neural network operations using relational predicates:

  • mat_vec(M, V_in, V_out): Matrix-vector multiplication
  • vec_add(A, B, C): Vector addition
  • activation(V_in, V_out): Activation function application

This declarative approach enables:

  • Compositional reasoning about network structure
  • Potential for bidirectional inference
  • Natural integration with logic programming systems
  • Prolog-style rule export for interpretability

Includes:

  • Python implementation (PredicateMLP.py) with PyTorch backend
  • F# implementation (PredicateMLP.fs) for inference engine
  • Comprehensive test suite (test_predicate_mlp.py)

Implements neural network operations using relational predicates:
- mat_vec(M, V_in, V_out): Matrix-vector multiplication
- vec_add(A, B, C): Vector addition
- activation(V_in, V_out): Activation function application

This declarative approach enables:
- Compositional reasoning about network structure
- Potential for bidirectional inference
- Natural integration with logic programming systems
- Prolog-style rule export for interpretability

Includes:
- Python implementation (PredicateMLP.py) with PyTorch backend
- F# implementation (PredicateMLP.fs) for inference engine
- Comprehensive test suite (test_predicate_mlp.py)
Implements MLP inference using relational predicates:
- mat_vec(M, V_in, V_out): Matrix-vector multiplication
- vec_add(A, B, C): Vector addition
- activation(Type, V_in, V_out): Activation functions

New files:
- sro_decoder_mlp.pl: Core MLP predicates for inference
- tensor_autodiff.pl: Computation graph with automatic differentiation
  - dense(W, B, In, Out): Dense layer building graph node
  - relu/swish/sigmoid(In, Out): Activations with grad functions
  - mse(Exp, Act, Loss): Loss function
  - backward(Loss, Gradients): Backpropagation via chain rule
- export_weights_to_prolog.py: Convert PyTorch weights to Prolog facts
- example_weights.pl: Sample weights for testing

The autodiff module builds execution graphs suitable for automatic
differentiation by recording operations and their gradient functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants