Chapter 28

layers/metacognition

github.com/openfluke/welvet/layers/metacognition


Why it exists

Observed layers can apply heuristic stability rules (gate/scale/reset) without dtype morph/QAT.

What it is

Wraps Dense + DefaultStabilityRules(); Stats exposed. Full timed matrix + train grids.

Go example

examples/28-metacognition/main.go

Run:cd welvet/examples/28-metacognition && source ../env.sh && go run .
package main

import (
	"fmt"

	"github.com/openfluke/welvet/core"
	"github.com/openfluke/welvet/layers/metacognition"
)

func main() {
	l, err := metacognition.New(metacognition.Config{
		Dim: 16, Rules: metacognition.DefaultStabilityRules(),
	})
	if err != nil {
		panic(err)
	}
	x := core.NewTensor[float32](1, 16)
	_, y, err := metacognition.Forward(l, x)
	fmt.Println(len(y.Data), err)
}

Output

exit 0 · last run via go run .

16 <nil>