// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-one-neuron.t27 -- lesson 25 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-one-neuron/ (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-one-neuron/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_one_neuron; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-one-neuron"; pub const TITLE : str = "One ternary neuron: inputs, weights, a threshold"; pub const DESCRIPTION : str = "Nine inputs and nine weights of -1, 0, +1. Each product is a copy, a zero or a flip; the sum against a threshold gives an output trit."; pub const IMAGE_ALT : str = "One neuron card: a vertical bar on a 3 x 3 grid of -1 and +1, nine weights tuned to vertical bars, the products all +1, the sum 9 above the threshold 2: the neuron fires +1."; pub const HOOK : str = "A neuron with ternary weights has no multiplier inside: just copies, zeros and flips, then a sum."; 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_THRESHOLD : i32 = 2; 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_WEIGHTS : str = "weights (press a cell)"; pub const SAY_PRODUCTS : str = "products"; pub const SAY_FIRE : str = "sum {0}: output {1}"; pub const SAY_HOW : str = "Output +1 at or above the threshold, -1 at or below minus it, 0 between: a neuron that can say \"not sure\"."; 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 == 2; }