perforatedai.dendrite_axis_codes
Semantic codes for the entries of a module's output-dimensions specification.
A module's output_dimensions (the global default lives in
globals_perforatedai.PAIConfig.output_dimensions) and the per-module
this_output_dimensions buffer are lists with one entry per tensor axis. Each
entry is one of the fixed codes defined here, describing how the covariance
machinery treats that axis:
REDUCE_AXIS(-1): a pure sample axis. It is summed/averaged away, so it does not appear in the per-node score. This is the batch axis, and by default the spatial height and width of a convolution.NODE_AXIS(0): the single node/channel axis. Exactly one entry must beNODE_AXIS; its length is the number of output nodes (out_channels), and the covariance is computed to produce one score per position along it. Its index is cached asthis_node_index.NOT_REDUCE_OR_NODE_AXIS(1): an additional retained axis. It is kept (never reduced), but it is not the node axis; each position along it receives its own score, so the result carries one covariance value per combination of node index and retained-axis position.
These are constants.
This module intentionally imports nothing so it can be imported from anywhere
in either the perforatedai or perforatedbp libraries
without creating an import cycle.
1"""Semantic codes for the entries of a module's output-dimensions specification. 2 3A module's ``output_dimensions`` (the global default lives in 4``globals_perforatedai.PAIConfig.output_dimensions``) and the per-module 5``this_output_dimensions`` buffer are lists with one entry per tensor axis. Each 6entry is one of the fixed codes defined here, describing how the covariance 7machinery treats that axis: 8 9- ``REDUCE_AXIS`` (``-1``): a pure sample axis. It is summed/averaged away, so it 10 does not appear in the per-node score. This is the batch axis, and by default 11 the spatial height and width of a convolution. 12- ``NODE_AXIS`` (``0``): the single node/channel axis. Exactly one entry must be 13 ``NODE_AXIS``; its length is the number of output nodes (``out_channels``), and 14 the covariance is computed to produce one score per position along it. Its 15 index is cached as ``this_node_index``. 16- ``NOT_REDUCE_OR_NODE_AXIS`` (``1``): an additional retained axis. It is kept 17 (never reduced), but it is not the node axis; each position along it receives 18 its own score, so the result carries one covariance value per combination of 19 node index and retained-axis position. 20 21These are constants. 22 23This module intentionally imports nothing so it can be imported from anywhere 24in either the ``perforatedai`` or ``perforatedbp`` libraries 25 without creating an import cycle. 26""" 27 28__all__ = ["REDUCE_AXIS", "NODE_AXIS", "NOT_REDUCE_OR_NODE_AXIS"] 29 30REDUCE_AXIS: int = -1 31NODE_AXIS: int = 0 32NOT_REDUCE_OR_NODE_AXIS: int = 1
REDUCE_AXIS: int =
-1
NODE_AXIS: int =
0
NOT_REDUCE_OR_NODE_AXIS: int =
1