math: expose error sensitivity signal - #1
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
ActivationFunction.derivativeFromOutput(y)— sigmoid uses they(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 }, whereerror = target − predictionandupdateSignal = error · sensitivity.E,f′, andE·f′next to the evaluation and feedback action.Input → … → Feedback Actiondiagram, the output-derivative identity, and worked values tied to example 02's prediction.examplesscript 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 signalmaps to harnessrun violation → diagnosis → update candidate.Verification
pnpm typecheck✓pnpm build✓pnpm test✓ (40 tests; math now 16)error E = 0.507856,f′ = 0.249938,update signal = 0.126933Test plan
derivativeFromOutput(sigmoid/relu/identity)errorSensitivity(signal fields + zero-error case)pnpm --filter @composable-model-graph/example-03-error-sensitivity-feedback startMade with Cursor