| Crates.io | amari-fusion |
| lib.rs | amari-fusion |
| version | 0.17.0 |
| created_at | 2025-10-06 20:45:19.98794+00 |
| updated_at | 2026-01-11 22:36:52.822611+00 |
| description | Fusion system for combining algebraic structures |
| homepage | https://github.com/justinelliottcobb/Amari |
| repository | https://github.com/justinelliottcobb/Amari |
| max_upload_size | |
| id | 1870828 |
| size | 242,691 |
Tropical-Dual-Clifford fusion algebra with holographic associative memory.
amari-fusion combines three algebraic systems into a unified framework:
This fusion creates a powerful framework for neural network evaluation, optimization, and geometric machine learning. The TropicalDualClifford (TDC) type also serves as the foundation for holographic associative memory - a brain-inspired memory system that stores key-value pairs in superposition using Vector Symbolic Architecture (VSA) principles.
The holographic feature provides a complete implementation of holographic reduced representations:
⊛): Associates keys with values using geometric product⊕): Superimposes multiple associations into a single traceAdd to your Cargo.toml:
[dependencies]
amari-fusion = "0.12"
[dependencies]
# Default features
amari-fusion = "0.12"
# Enable holographic memory
amari-fusion = { version = "0.12", features = ["holographic"] }
# With parallel processing
amari-fusion = { version = "0.12", features = ["rayon"] }
use amari_fusion::TropicalDualClifford;
// Create from logits (common in ML applications)
let logits = vec![1.5, 2.0, 0.8, 1.2];
let tdc = TropicalDualClifford::<f64, 4>::from_logits(&logits);
// Evaluate against another TDC
let other = TropicalDualClifford::from_logits(&[2.0, 1.5, 1.0, 0.9]);
let evaluation = tdc.evaluate(&other);
println!("Combined score: {}", evaluation.combined_score);
// Extract features from each algebra
let tropical_features = tdc.extract_tropical_features();
let dual_features = tdc.extract_dual_features();
// Sensitivity analysis
let sensitivity = tdc.sensitivity_analysis();
let most_sensitive = sensitivity.most_sensitive(2);
println!("Most sensitive components: {:?}", most_sensitive);
use amari_fusion::holographic::{HolographicMemory, BindingAlgebra, Bindable};
use amari_fusion::TropicalDualClifford;
// Create a holographic memory
let mut memory = HolographicMemory::<f64, 8>::new(BindingAlgebra::default());
// Store key-value associations
let key1 = TropicalDualClifford::random();
let value1 = TropicalDualClifford::random();
memory.store(&key1, &value1);
let key2 = TropicalDualClifford::random();
let value2 = TropicalDualClifford::random();
memory.store(&key2, &value2);
// Retrieve with a key
let result = memory.retrieve(&key1);
println!("Confidence: {:.2}", result.confidence);
println!("Retrieved value similarity: {:.2}", result.value.similarity(&value1));
// Check capacity
let info = memory.capacity_info();
println!("Items stored: {}", info.item_count);
println!("Estimated SNR: {:.2}", info.estimated_snr);
For noisy inputs, the resonator iteratively cleans up retrieved values:
use amari_fusion::holographic::{Resonator, ResonatorConfig};
// Create a codebook of clean reference vectors
let codebook: Vec<TropicalDualClifford<f64, 8>> = (0..10)
.map(|_| TropicalDualClifford::random_vector())
.collect();
// Configure the resonator
let config = ResonatorConfig {
max_iterations: 10,
convergence_threshold: 0.99,
..Default::default()
};
let resonator = Resonator::new(&codebook, config);
// Clean up a noisy input
let noisy_input = codebook[3].clone(); // Add some noise in practice
let result = resonator.cleanup(&noisy_input);
println!("Converged: {}", result.converged);
println!("Best match index: {}", result.best_match_index);
println!("Iterations: {}", result.iterations);
Fast approximation using max-plus operations:
softmax(x) ≈ max(x) (in log-space)
Benefits:
Exact gradient computation:
// Automatic derivatives without backpropagation graphs
let grads = tdc.extract_dual_features();
Benefits:
Geometric relationships:
// Spatial reasoning in the unified system
let geometric = tdc.clifford_repr();
Benefits:
The holographic memory has a theoretical capacity of approximately:
C ≈ D / ln(D)
where D is the dimensionality (e.g., 8 for TropicalDualClifford<_, 8>). Beyond this capacity, retrieval quality degrades gracefully.
The estimated SNR is:
SNR ≈ √(D / N)
where N is the number of stored items. Higher SNR means more reliable retrieval.
The binding operation satisfies important algebraic properties:
use amari_fusion::holographic::Bindable;
let a = TropicalDualClifford::<f64, 8>::random_vector();
let b = TropicalDualClifford::<f64, 8>::random_vector();
// Binding produces dissimilar results
let bound = a.bind(&b);
assert!(bound.similarity(&a).abs() < 0.3);
assert!(bound.similarity(&b).abs() < 0.3);
// Binding is approximately invertible for unit vectors
let recovered_b = bound.unbind(&a);
let b_similarity = recovered_b.similarity(&b);
// Identity element
let identity = TropicalDualClifford::<f64, 8>::binding_identity();
let with_identity = a.bind(&identity);
assert!(with_identity.similarity(&a) > 0.9);
use amari_fusion::{TropicalDualClifford, optimizer::TDCOptimizer};
let initial = TropicalDualClifford::from_logits(¶ms);
let optimizer = TDCOptimizer::new()
.with_tropical_warmup(5) // Fast tropical approximation
.with_dual_refinement(10) // Exact dual gradients
.with_clifford_projection(); // Geometric constraints
let optimized = optimizer.optimize(&initial, &loss_fn)?;
amari-fusion/
├── src/
│ ├── lib.rs # Main entry, TropicalDualClifford type
│ ├── types.rs # Core fusion types
│ └── holographic/ # Holographic memory module (feature-gated)
│ ├── mod.rs # Module exports
│ ├── binding.rs # Bind/bundle operations, Bindable trait
│ ├── memory.rs # HolographicMemory implementation
│ ├── resonator.rs # Resonator cleanup
│ └── verified.rs # Formal verification contracts
The fusion system provides performance benefits from each component:
| Component | Benefit |
|---|---|
| Tropical | O(n) vs O(n log n) for softmax-like operations |
| Dual | No graph storage, O(1) memory overhead |
| Clifford | Unified rotations, no gimbal lock |
| Holographic | O(D) storage per item, graceful degradation |
store_batch() for efficient bulk storagerayon feature for parallel bundle operationsamari-gpu for GPU-accelerated holographic operationsLicensed under either of:
at your option.
This crate is part of the Amari mathematical computing library.