matrix subtract for filters
Subtract a matrix or scalar from a matrix.
Signature
> matrix subtract {flags} (other)
Flags
--broadcast, -b: Enable broadcasting to allow compatible shapes
Parameters
other: The other matrix or scalar to subtract.
Input/output types:
| input | output |
|---|---|
| matrix | matrix |
Examples
Subtract a scalar from a matrix
> matrix zeros 2 2 | matrix add 5 | matrix subtract 2 | matrix into-nu | to nuon
[[3.0, 3.0], [3.0, 3.0]]Subtract two matrices element-wise
> matrix identity 2 | matrix add 5 | matrix subtract (matrix identity 2) | matrix into-nu | to nuon
[[5.0, 5.0], [5.0, 5.0]]Subtract with broadcasting a row vector
> matrix zeros 2 3 | matrix add 5 | matrix subtract --broadcast ([[1.0 2.0 3.0]] | into matrix) | matrix into-nu | to nuon
[[4.0, 3.0, 2.0], [4.0, 3.0, 2.0]]