Skip to content

math: expose error sensitivity signal - #1

Merged
bigboateng merged 1 commit into
mainfrom
pr3-error-sensitivity-signal
Jun 5, 2026
Merged

math: expose error sensitivity signal#1
bigboateng merged 1 commit into
mainfrom
pr3-error-sensitivity-signal

Conversation

@bigboateng

Copy link
Copy Markdown
Contributor

Summary

PR 3: make the feedback signal explicit. A run now exposes not just prediction + error, but the local sensitivity and the resulting correction pressure.

ŷ → E → f′ → E·f′ → feedback
  • ActivationFunction.derivativeFromOutput(y) — sigmoid uses the y(1 − y) identity available straight off a forward pass (relu: y>0?1:0, identity: 1).
  • errorSensitivity(activation, prediction, target){ prediction, target, error, sensitivity, updateSignal }, where error = target − prediction and updateSignal = error · sensitivity.
  • Example 03 rewritten to run the neural graph, then print E, f′, and E·f′ next to the evaluation and feedback action.
  • Docs: explicit Input → … → Feedback Action diagram, the output-derivative identity, and worked values tied to example 02's prediction.
  • Root examples script to run all examples in sequence.

Still no training/backprop — this only exposes the signal that would drive an update. This is the bridge: neural prediction error → derivative → update signal maps to harness run violation → diagnosis → update candidate.

Verification

  • pnpm typecheck
  • pnpm build
  • pnpm test ✓ (40 tests; math now 16)
  • Example 03 output: error E = 0.507856, f′ = 0.249938, update signal = 0.126933

Test plan

  • math unit tests for derivativeFromOutput (sigmoid/relu/identity)
  • math unit tests for errorSensitivity (signal fields + zero-error case)
  • pnpm --filter @composable-model-graph/example-03-error-sensitivity-feedback start

Made with Cursor

Make the feedback signal explicit so a run shows not just prediction + error,
but the local sensitivity and the resulting correction pressure:

  ŷ → E → f′ → E·f′ → feedback

- Add ActivationFunction.derivativeFromOutput(y); sigmoid uses the y(1-y)
  identity available right after a forward pass (relu: y>0?1:0, identity: 1).
- Add errorSensitivity(activation, prediction, target) returning
  { prediction, target, error, sensitivity, updateSignal } where
  error = target - prediction and updateSignal = error * sensitivity.
- Rewrite example 03 to run the neural graph and print E, f′, and E·f′
  alongside the evaluation and feedback action.
- Document the explicit Input→…→Feedback diagram, the output-derivative
  identity, and worked values tied to example 02's prediction.
- Add a root `examples` script to run all examples in sequence.

No training/backprop: this only exposes the signal that would drive an update.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants