// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-tiny-layer.t27 -- lesson 27 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-tiny-layer/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles this ; file, checks its constants, evaluates the tests below and writes the page; the page hands every constant to ; tool.js as window.T27_WIDGET. tool.js draws through ../ternary-kit.js and computes nothing: every number comes ; from public/widgets/tc-tiny-layer/logic.js, the fn bodies of the gHashTag/t27 spec in logic.t27, compiled to wasm. ; ASCII only (L3), English only (LANG-EN). ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_tc_tiny_layer; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-tiny-layer"; pub const TITLE : str = "A layer of three ternary neurons"; pub const DESCRIPTION : str = "Three neurons share one input: a vertical, a horizontal and a diagonal detector. Draw on the input and read three output trits."; pub const IMAGE_ALT : str = "Tiny layer card: one 3 x 3 input, a vertical bar, feeding three neurons with vertical, horizontal and diagonal weights; the outputs read +1, 0, 0: only the vertical detector fires."; pub const HOOK : str = "A layer is several neurons reading the same input. Three trits out describe what the picture is."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [2]str = ["gHashTag/t27 specs/ternary/trits.t27 (t27#8979): every value on the page is its fn bodies, compiled to wasm (logic.js), with 18 tests and 4108 runtime asserts", "S. Ma and others, The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits, 2024: weights of -1, 0 and +1"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; pub const K_CARD_WIDTH : u16 = 1200; pub const K_CARD_HEIGHT : u16 = 630; pub const SAY_LOADING : str = "Loading"; pub const K_PATTERNS : [45]i32 = [-1, 1, -1, -1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, 0, 0, 1, -1, -1, 0, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1]; pub const K_W0 : [9]i32 = [-1, 1, -1, -1, 1, -1, -1, 1, -1]; pub const K_W1 : [9]i32 = [-1, -1, -1, 1, 1, 1, -1, -1, -1]; pub const K_W2 : [9]i32 = [1, -1, -1, -1, 1, -1, -1, -1, 1]; pub const K_THRESHOLD : i32 = 5; pub const SAY_PICK : str = "Input"; pub const SAY_PATTERNS : [5]str = ["vertical bar", "horizontal bar", "diagonal", "noise", "inverted bar"]; pub const SAY_TH : str = "Threshold"; pub const SAY_INPUT : str = "input (press a cell)"; pub const SAY_NEURONS : [3]str = ["vertical", "horizontal", "diagonal"]; pub const SAY_SUM : str = "sum {0}"; pub const SAY_LAYER : str = "outputs: {0}"; pub const SAY_HOW : str = "Each neuron is the one from the last lesson with its own weights. Together they classify."; pub const SAY_SOURCE : str = "Logic: t27 spec ternary/trits.t27, compiled"; test the_card_is_the_share_size { assert K_CARD_WIDTH == 1200; assert K_CARD_HEIGHT == 630; assert K_CARD_WIDTH * 21 == K_CARD_HEIGHT * 40; } test the_widget_starts_where_its_card_says { assert K_THRESHOLD == 5; }