AxisRelation
Models & Types · AiDotNet.Interfaces
How ONE output axis is sized from the input axes and the declaring type’s own configuration.
How It Works
The symbolic half of the shape system. [TensorLayout] says WHICH axes a layer has and in what
order; this says HOW BIG each output axis is. Roles alone cannot distinguish a stride-1 convolution
from a stride-2 one — both declare [Batch, Channels, Height, Width] in and out — yet one halves
the spatial extent. Without the relation, “automatic shape inference” can only propagate names.
A RELATION, NOT A CONSTANT. Every form below is evaluated against the actual input at resolve time
and reads the declaring instance’s real options, so a layer built with stride: 2 reports the
halving and one built with stride: 1 does not. That is the whole reason this is an interface
rather than more attribute arguments: C# attributes take compile-time constants only, and kernel,
stride, padding and scale factor are all constructor arguments. A declaration that cannot see the
configuration it describes is a declaration that goes stale the first time someone passes a different
stride.
Properties
| Property | Summary |
|---|---|
Form Kind { get; } |
Which form this relation takes. |
IReadOnlyList<AxisRelation> Factors { get; } |
The factors, for ProductOfRelations; empty for every other form. |
IReadOnlyList<TensorAxis> Sources { get; } |
Input axes this output axis is computed from. |
int Denominator { get; } |
Scale denominator, for Scaled. |
int Dilation { get; } |
Window dilation, for Window. |
int Kernel { get; } |
Window extent, for Window. |
int Numerator { get; } |
Scale numerator, for Scaled. |
int Padding { get; } |
Padding added to BOTH sides, for Window. |
int Stride { get; } |
Window step, for Window. |
int Value { get; } |
The size, for Fixed. |
string Reason { get; } |
Why the size is unknown, for Unknown. |
Methods
| Method | Summary |
|---|---|
AxisRelation Affine(TensorAxis source, int numerator, int denominator, int offset) |
This output axis is an input axis scaled by numerator/denominator and then shifted by offset, which MAY be negative. |
AxisRelation Fixed(int size) |
This output axis has a size the configuration fixes, whatever the input. |
AxisRelation FromPort(int port, TensorAxis axis) |
This output axis copies an axis of a SPECIFIC input port. |
AxisRelation Product(TensorAxis[] sources) |
This output axis is the product of several input axes — a flatten. |
AxisRelation ProductOf(AxisRelation[] factors) |
This output axis is the product of several DERIVED relations — a flatten over axes that are each transformed first. |
AxisRelation Same(TensorAxis source) |
This output axis copies an input axis unchanged. |
AxisRelation Scaled(TensorAxis source, int numerator, int denominator) |
This output axis is an input axis scaled by numerator/denominator. |
AxisRelation ScaledBy(AxisRelation source, int numerator, int denominator) |
This output axis is another RELATION scaled by numerator/denominator. |
AxisRelation SumOf(AxisRelation[] terms) |
This output axis is the SUM of several relations — what a concatenation does to its joined axis. |
AxisRelation Unknown(string reason) |
This output axis genuinely cannot be derived from the input shape. |
AxisRelation Window(TensorAxis source, int kernel, int stride, int padding, int dilation) |
This output axis follows the sliding-window formula floor((in + 2*padding - dilation*(kernel-1) - 1) / stride) + 1. |
bool TryResolve(IReadOnlyDictionary<TensorAxis, int> inputAxes, int size) |
Computes this axis’s size from SEVERAL input ports’ axis sizes. |
bool TryResolve(IReadOnlyList<IReadOnlyDictionary<TensorAxis, int>> ports, int size) |
Computes this axis’s size from SEVERAL input ports’ axis sizes. |
string ToString() |