Upload matrixpfn-base v0.1.0
Browse files
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: matrixpfn
|
| 3 |
+
tags:
|
| 4 |
+
- preconditioner
|
| 5 |
+
- sparse-linear-systems
|
| 6 |
+
- graph-neural-network
|
| 7 |
+
- pytorch
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# matrixpfn-base
|
| 11 |
+
|
| 12 |
+
GNN-based learned preconditioner for sparse linear systems.
|
| 13 |
+
|
| 14 |
+
**Version**: 0.1.0
|
| 15 |
+
|
| 16 |
+
## Usage
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
import numpy as np
|
| 20 |
+
from scipy.io import mmread
|
| 21 |
+
from matrixpfn import MatrixPFN
|
| 22 |
+
|
| 23 |
+
pfn = MatrixPFN.from_pretrained("Csed-dev/matrixpfn-base")
|
| 24 |
+
|
| 25 |
+
A = mmread("matrix.mtx") # any scipy sparse matrix
|
| 26 |
+
b = A @ np.random.randn(A.shape[0])
|
| 27 |
+
|
| 28 |
+
result = pfn.solve(A, b) # accepts scipy sparse directly
|
| 29 |
+
print(f"Converged: {result.converged} in {result.iterations} iterations")
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Architecture
|
| 33 |
+
|
| 34 |
+
| Parameter | Value |
|
| 35 |
+
|-----------|-------|
|
| 36 |
+
| Network | ContextResGCN |
|
| 37 |
+
| Layers | 12 |
|
| 38 |
+
| Embed | 64 |
|
| 39 |
+
| Hidden | 256 |
|
| 40 |
+
| Context pairs | 10 |
|
| 41 |
+
| Parameters | 419,074 |
|
| 42 |
+
| dtype | float32 |
|
| 43 |
+
|
| 44 |
+
## Training
|
| 45 |
+
|
| 46 |
+
- **epochs**: 2000
|
| 47 |
+
- **best_loss**: 0.071401
|
| 48 |
+
- **loss_function**: l1_direct
|
| 49 |
+
- **batch_size**: 512
|
| 50 |
+
- **domains**: diffusion, diffusion_advection
|
| 51 |
+
- **grid_sizes**: [16, 24, 32, 48]
|
| 52 |
+
|
| 53 |
+
## Benchmark
|
| 54 |
+
|
| 55 |
+
| domain | grid | converged | avg_iters | avg_residual |
|
| 56 |
+
|--------|------|-----------|-----------|--------------|
|
| 57 |
+
| diffusion | 16x16 | 0/20 | 300.0 | 5.06e-02 |
|
| 58 |
+
| diffusion | 24x24 | 0/20 | 300.0 | 3.02e-02 |
|
| 59 |
+
| diffusion | 32x32 | 0/20 | 300.0 | 2.51e-02 |
|
| 60 |
+
| diffusion | 48x48 | 0/20 | 300.0 | 1.71e-02 |
|
| 61 |
+
| diffusion | 64x64 | 0/20 | 300.0 | 9.03e-03 |
|
| 62 |
+
| diffusion_advection | 16x16 | 20/20 | 87.7 | 6.12e-09 |
|
| 63 |
+
| diffusion_advection | 24x24 | 7/20 | 263.1 | 5.34e-04 |
|
| 64 |
+
| diffusion_advection | 32x32 | 0/20 | 300.0 | 5.15e-03 |
|
| 65 |
+
| diffusion_advection | 48x48 | 0/20 | 300.0 | 2.14e-02 |
|