cobb-douglas-neuron
v1.0.0
Published
Experimental comparison of a classical (degree-0) neuron against a degree-(+1) Cobb-Douglas neuron, derived from the logarithmic-exponential conjugation principle.
Downloads
136
Maintainers
Readme
cobb-douglas-neuron
An experimental comparison of a classical (degree-0) neuron against a degree-(+1) Cobb-Douglas neuron, derived from the logarithmic-exponential conjugation principle.
This repository is the sibling of conjugate-neuron. Where conjugate-neuron explored the degree (-1) displacement (LogSumExp / microstate neuron), this repo explores the degree (+1) displacement — the Cobb-Douglas neuron.
The mathematical core
The conjugation principle defines an infinite hierarchy of binary operations *_k:
a *_k+1 b = exp( log(a) *_k log(b) )Setting *_0 = + gives:
| Degree | Operation | Closed form |
|--------|-----------|-------------|
| -1 | *_{-1} | log(e^a + e^b) (LogSumExp) |
| 0 | + | a + b (addition) |
| 1 | × | a · b (multiplication) |
| 2 | *_2 | exp(log a · log b) = a^{log b} (new operation) |
The Cobb-Douglas neuron (degree +1)
A classical neuron uses × (degree 1) to combine weights and inputs, and + (degree 0) to aggregate:
z = Σ_i w_i · x_i + bA degree-(+1) neuron displaces both operations up one level: combination becomes *_2 (degree 2), aggregation becomes × (degree 1):
z = b · ∏_i (w_i *_2 x_i)
= b · ∏_i exp(log w_i · log x_i)
= b · ∏_i x_i^{log w_i}This is the Cobb-Douglas production function from economics (Cobb & Douglas, 1928), where log(w_i) plays the role of elasticities. The neuron is mathematically equivalent to a classical neuron operating on log-features, but with multiplicative backpropagation — the gradient scales with the output z.
What the experiment tests
For each dataset, the runner trains two single neurons under identical conditions:
| | Classical neuron (degree 0) | Cobb-Douglas neuron (degree +1) |
|---|---|---|
| Pre-activation | z = Σ wᵢxᵢ + b | z = b · ∏ xᵢ^{log wᵢ} |
| Combination op | × | *_2 = a^{log b} |
| Aggregation op | Σ | ∏ (product) |
| Gradient dynamics | Additive (independent of z) | Multiplicative (scales with z) |
| Positivity constraint | None | Weights and inputs must be > 0 |
| Natural domain | Linear/additive data | Multiplicative/power-law data |
Both share the same optimizer, learning rate, seed, and epoch budget. The only independent variable is the arithmetic.
Datasets
| Dataset | Structure | Expected winner |
|---------|-----------|-----------------|
| Cobb-Douglas | y = ∏ xᵢ^{αᵢ} (multiplicative) | Cobb-Douglas neuron |
| Power law | y = x^α (single input) | Cobb-Douglas neuron |
| Log-normal mixtures | Multiplicative analog of Gaussian mixtures | Cobb-Douglas (by structure) |
| Linear | y = Σ wᵢxᵢ + b (additive) | Classical neuron |
| XOR | Additive boolean (shifted to positive) | Neither (single-neuron ceiling) |
Quick start
git clone https://github.com/Justo-Tapiador/cobb-douglas-neuron.git
cd cobb-douglas-neuron
npm install
npm start
# → open http://localhost:3000Or headless:
npm start -- --headless --dataset cobb-douglas --epochs 300 --lr 0.05Key experimental results
Preliminary results (single neuron, Adam, 300 epochs, lr=0.05):
| Dataset | Classical loss | Cobb-Douglas loss | Winner | |---------|---------------|-------------------|--------| | Cobb-Douglas regression | 0.0154 | 0.0050 | Cobb-Douglas (3× lower loss) | | Power law y=x² | 0.414 | 0.041 | Cobb-Douglas (10× lower loss) | | Linear regression | 0.0062 | 0.134 | Classical (20× lower loss) | | Log-normal mixtures | 0.755 | 0.655 | Cobb-Douglas (lower loss) | | XOR | 0.693 | 0.520 | Both plateau at 50% acc |
Headline finding: the Cobb-Douglas neuron wins decisively on multiplicative data (3-10× lower loss) and loses decisively on additive data (20× higher loss). This confirms the hypothesis that the conjugation hierarchy provides arithmetics specialized to different data structures.
On Cobb-Douglas regression, the neuron recovers the true elasticities α_i as log(effective_w_i) — e.g. true [0.5, 0.3, 0.2] → recovered [0.52, 0.25, 0.25].
Repository structure
cobb-douglas-neuron/
├── src/
│ ├── arithmetic/
│ │ ├── Arithmetic.ts ← the interface
│ │ ├── ClassicalArithmetic.ts ← degree 0: ×, +
│ │ ├── CobbDouglasArithmetic.ts ← degree +1: *_2, × (with softplus weights)
│ │ └── index.ts
│ ├── tensor/ ← Vector, Matrix, RNG
│ ├── nn/ ← Parameter, Neuron (softplus), Layer, Network
│ ├── activations/ ← Identity, Sigmoid, Tanh, ReLU
│ ├── losses/ ← MSE, BCE, CrossEntropy
│ ├── optimizers/ ← SGD, Adam
│ ├── datasets/ ← Cobb-Douglas, power-law, log-normal, XOR, linear
│ ├── experiments/ ← ExperimentRunner, runComparison
│ ├── server/ ← Express + WebSocket dashboard
│ │ └── public/ ← HTML/CSS/JS with Chart.js
│ ├── main.ts ← CLI entry point
│ └── index.ts ← public library entry point
├── tests/
│ └── arithmetic.test.ts ← 10 unit tests
└── docs/
└── theory.md ← mathematical backgroundLicense
MIT — see LICENSE.
Related work
- conjugate-neuron — the sibling repo exploring degree (-1) (LogSumExp / microstate neuron)
- The conjugation principle papers (J. Tapiador García) — see
docs/theory.md
