Context-Controlled Linear Mappings Using Binary Sign Flips
Context-Controlled Linear Mappings Using Binary Sign Flips and Fast Walsh–Hadamard Transforms
1. Generating a constrained binary context
The first component constructs a binary context vector from analog control signals and fixed Gaussian random vectors.
Begin with analog signals, for example random projections of the input.
Associate each signal with a fixed random vector whose components are sampled from a Gaussian distribution.
Multiply each random vector by its corresponding analog signal and sum the weighted vectors.
Binarize the resulting vector into +1 and -1 values.
The result is a binary context that controls the signs of selected input dimensions.
This construction provides a way to restrict the binary context space. Although an m-dimensional binary vector has 2ⁿ possible patterns in principle, a low-dimensional analog control process will reach only a subset of them. The context mechanism can therefore introduce useful variation without necessarily exposing the trainable mapping to arbitrary, unconstrained changes in geometry.
The analog signals might be generated using random projections, a fast Walsh–Hadamard transform (WHT), or other fixed measurements. The weighted random-vector combinations can be calculated directly, or can be created with the aid of the WHT.
2. Context constructs a different linear mapping
Let x be the input vector, H a normalized Walsh–Hadamard matrix, and D(c) a diagonal matrix containing the binary context values.
The context-controlled transformation is:
u = HD(c) xMultiplying H on the right by D(c) flips the signs of selected columns of H. Each context pattern therefore constructs a particular signed version of the WHT matrix.
The important point is that different contexts produce genuinely different linear mappings. When several context bits change, several columns of the WHT change sign. The resulting matrix can differ substantially from the matrix produced by another context.
This is not simply a label attached to an otherwise unchanged computation. The input is transformed into a different distributed configuration before reaching the adjustable component.
3. Adding an adjustable linear mapping
The context-controlled mapping can be composed with an adjustable matrix A:
y = AHD(c)xEquivalently, the effective matrix for context c is:
W(c) = AHD(c)Each context therefore has its own effective linear mapping, even though the same adjustable matrix A is shared across contexts.
The context determines which signed WHT mapping is used.
The adjustable matrix learns how to respond to the resulting input representation.
Backpropagation trains A using ordinary matrix operations; the context-generation mechanism is not trained.
A single set of adjustable parameters can consequently implement a family of context-specific mappings.
The context does not merely select a stored matrix. It constructs a different matrix through sign flips, and the shared adjustable component processes a different input state for each context.
4. Full and structured adjustable matrices
The adjustable component can be a full matrix or a structured matrix.
A full matrix offers maximum linear flexibility but requires O(n²) parameters. In this case, the WHT is optional: the context-dependent signed mapping can be followed directly by a full adjustable matrix. The WHT may still be useful, but its necessity is an empirical question.
The constrained context construction described in Part 1 remains relevant even when the adjustable matrix is full. Restricting the range of context variation may help prevent the effective mappings from varying in ways that the adjustable component cannot adequately compensate for or generalize across.
Alternatively, the adjustable component can consist of multiple small matrices, such as 16 × 16 blocks. A WHT before these blocks supplies global mixing, allowing each small matrix to operate on a representation influenced by all input coordinates. This may provide useful expressiveness with substantially fewer adjustable parameters.
The WHT thus offers a way to trade additional fixed computation for a smaller trainable component.
5. Full and partial WHTs
A full WHT provides one-to-all connectivity: every output coordinate depends on every input coordinate.
However, a full transform may not always be necessary. A fast WHT is implemented in stages, and early stages can be skipped to produce a partial transform. The remaining stages provide structured mixing at a lower computational cost.
Depending on the arrangement of the adjustable matrix, a partial WHT may provide sufficient connectivity for the combined mapping to be fully connected, even though the transform itself does not mix every coordinate with every other coordinate.
The choice between a full WHT, a partial WHT, or no WHT should be determined empirically. Relevant factors include parameter efficiency, computational cost, fitting quality, generalization, and the connectivity required by the adjustable component.
Summary
The architecture combines two forms of linear computation:
A context-controlled component constructs a mapping using binary sign flips, optionally combined with a full or partial fast Walsh–Hadamard transform.
An adjustable component learns a response through backpropagation and can be dense or structured.
The WHT can serve several roles: generating analog projections for context, constructing context-dependent mappings, and supplying global mixing that permits a compact trainable component.
The central design principle is to constrain how the effective mapping varies with context while retaining enough adjustable flexibility to learn the task. The context mechanism, transform structure, and adjustable matrix can be varied independently, making parameter efficiency and generalization empirical questions rather than assumptions.

### Some observations on context-dependent neural networks
ReplyDeleteA few interesting lessons have emerged from experimenting with context-dependent matrix switching.
- **Context complexity matters:** more context dimensions do not necessarily improve performance. Simpler context signals can produce excellent fitting and generalization.
- **Switching mechanisms matter:** independently trainable matrix elements can learn subtle differences between contexts, whereas binary sign flips offer a much more constrained choice.
- **Network depth matters:** sign-flip switching can work well in shallow networks, but successive context-dependent reflections can create increasingly complicated geometry, making optimization and generalization more difficult.
The broader lesson is that expressive power alone isn't enough. The complexity of the context, the flexibility of the switching mechanism, and network depth must work together.