Class SquashOp
- Namespace
- AiDotNet.JitCompiler.IR.Operations
- Assembly
- AiDotNet.dll
Represents Squash activation in the IR (for Capsule Networks).
public class SquashOp : IROp
- Inheritance
-
SquashOp
- Inherited Members
Remarks
Computes Squash(x) = (||x||^2 / (1 + ||x||^2)) * (x / ||x||). Used in capsule networks to ensure output vectors have length between 0 and 1.
Methods
Validate()
Validates that this operation is correctly formed.
public override bool Validate()
Returns
- bool
True if valid, false otherwise.
Remarks
Basic validation checks that the operation has required information. Derived classes can override to add operation-specific validation.
For Beginners: This checks that the operation makes sense.
Basic checks:
- Output ID is valid (non-negative)
- Has the right number of inputs
- Shapes are compatible
Specific operations add their own checks:
- MatMul: inner dimensions must match
- Conv2D: kernel size must be valid
- Reshape: total elements must be preserved
If validation fails, the operation can't be compiled.