Text Classification
English
code
FurkanNar commited on
Commit
a424144
Β·
verified Β·
1 Parent(s): 7e50385

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +183 -3
README.md CHANGED
@@ -1,3 +1,183 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - FurkanNar/StackMathematics
5
+ language:
6
+ - en
7
+ metrics:
8
+ - accuracy
9
+ base_model:
10
+ - FurkanNar/Spatial_Context_Networks
11
+ pipeline_tag: text-classification
12
+ tags:
13
+ - code
14
+ ---
15
+ # Spatial Context Networks (SCN)
16
+
17
+ > **Geometric Semantic Routing in Neural Architectures**
18
+ > Furkan Nar β€” Independent Researcher
19
+ > February 2026
20
+
21
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
22
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18599303.svg)](https://doi.org/10.5281/zenodo.18599303)
23
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/)
24
+ [![PyTorch 2.x](https://img.shields.io/badge/PyTorch-2.x-EE4C2C.svg)](https://pytorch.org/)
25
+
26
+ ---
27
+
28
+ ## Overview
29
+
30
+ Spatial Context Networks (SCN) is a novel neural architecture that treats neurons as **geometric entities in a learned semantic space**. Rather than relying on weighted linear combinations, each neuron operates as a point-mass with a learnable centroid β€” activating based on its distance to the input in that space.
31
+
32
+ This repository contains the reference PyTorch implementation accompanying the paper.
33
+
34
+ πŸ“„ **Paper:** [https://doi.org/10.5281/zenodo.18599303](https://doi.org/10.5281/zenodo.18599303)
35
+
36
+ ### Key Ideas
37
+
38
+ - **Geometric Activation** β€” activation inversely proportional to normalized Euclidean distance from a learnable centroid
39
+ - **Semantic Routing** β€” binary hard-routing that only activates neurons geometrically close to the input
40
+ - **Connection Density Weighting** β€” adaptive normalization that stabilizes signal magnitude across sparsity regimes
41
+ - **Pattern Distribution** β€” a Bayesian prior over output patterns via learnable softmax weights
42
+
43
+ ---
44
+
45
+ ## Architecture
46
+
47
+ ```
48
+ Input x ∈ ℝ^d
49
+ β”‚
50
+ β–Ό
51
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
52
+ β”‚ Semantic Routing Layer β”‚ ← Geometric activations + binary mask
53
+ β”‚ f(v) = 1 / (β€–vβˆ’ΞΌβ€–/√d + Ξ΅)β”‚
54
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
55
+ β”‚ activations, mask
56
+ β–Ό
57
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
58
+ β”‚ Connection Density Layer β”‚ ← Adaptive normalization + explosion control
59
+ β”‚ C = Ξ£ w_i / (Ξ±/z) β”‚
60
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
61
+ β”‚ context score
62
+ β–Ό
63
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
64
+ β”‚ Linear Projection β”‚
65
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
66
+ β”‚
67
+ β–Ό
68
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
69
+ β”‚ Pattern Distribution β”‚ ← h βŠ™ softmax(w_p)
70
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
71
+ β”‚
72
+ β–Ό
73
+ Output o ∈ ℝ^dout
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Installation
79
+
80
+ ```bash
81
+ git clone https://github.com/TheOfficialFurkanNar/spatial-context-networks.git
82
+ cd spatial-context-networks
83
+ pip install -e .
84
+ ```
85
+ ---
86
+
87
+ ## Quick Start
88
+
89
+ ```python
90
+ import torch
91
+ from model.py import SpatialContextNetwork
92
+
93
+ # Instantiate the model
94
+ model = SpatialContextNetwork(
95
+ input_dim=10,
96
+ n_neurons=32,
97
+ output_dim=4,
98
+ routing_threshold=0.5,
99
+ stability_factor=10.0,
100
+ explosion_threshold=2.0,
101
+ )
102
+
103
+ # Forward pass
104
+ x = torch.randn(8, 10)
105
+ output = model(x) # shape: (8, 4)
106
+
107
+ # Diagnostic stats
108
+ stats = model.get_network_stats(x)
109
+ print(f"Network efficiency: {stats['network_efficiency']:.1%}")
110
+ print(f"Mean active neurons: {stats['mean_active_neurons']:.1f} / 32")
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Training
116
+
117
+ ```bash
118
+ python train.py \
119
+ --input_dim 10 \
120
+ --n_neurons 32 \
121
+ --output_dim 4 \
122
+ --epochs 50 \
123
+ --batch_size 8 \
124
+ --lr 1e-3 \
125
+ --save_path scn_model.pt
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Inference
131
+
132
+ ```bash
133
+ python inference.py --checkpoint scn_model.pt --batch_size 8
134
+ ```
135
+
136
+ ---
137
+
138
+ ## Hyperparameters
139
+
140
+ | Parameter | Default | Description |
141
+ |-----------|---------|-------------|
142
+ | `input_dim` | 10 | Input feature dimensionality |
143
+ | `n_neurons` | 32 | Number of geometric hidden neurons |
144
+ | `output_dim` | 4 | Output dimensionality |
145
+ | `routing_threshold` Ο„ | 0.5 | Minimum activation to route through a neuron |
146
+ | `stability_factor` SF | 10.0 | Ξ΅ = 1/SF; prevents division by zero at centroid |
147
+ | `explosion_threshold` Ο„_exp | 2.0 | Context scores above this get √ damped |
148
+
149
+ ---
150
+
151
+ ## Results (Proof-of-Concept)
152
+
153
+ | Metric | Value |
154
+ |--------|-------|
155
+ | Mean active neurons | 29.1 / 32 |
156
+ | Network efficiency | 91% |
157
+ | Mean context score | 0.444 |
158
+ | Total parameters | ~500 |
159
+ | Hardware | Consumer gaming laptop (RTX) |
160
+
161
+ ---
162
+
163
+ ## Citation
164
+
165
+ If you use this work, please cite:
166
+
167
+ ```bibtex
168
+ @article{nar2026scn,
169
+ title = {Spatial Context Networks: Geometric Semantic Routing in Neural Architectures},
170
+ author = {Nar, Furkan},
171
+ year = {2026},
172
+ month = {February},
173
+ doi = {10.5281/zenodo.18599303},
174
+ url = {https://doi.org/10.5281/zenodo.18599303},
175
+ note = {Independent research. Published on Zenodo and Academia.edu}
176
+ }
177
+ ```
178
+
179
+ ---
180
+
181
+ ## License
182
+
183
+ [MIT](LICENSE) Β© 2026 Furkan Nar