Skip to content

Commit 837b806

Browse files
committed
update docs and the test
1 parent 23efe1b commit 837b806

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

docs/Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,9 @@ This version of the operator has been available since version 1 of the default O
21772177
### <a name="LpNormalization-1"></a>**LpNormalization-1**</a>
21782178

21792179
Given a matrix, apply Lp-normalization along the provided axis.
2180+
The output is computed as: `output = input / Lp_norm(input, axis)`.
2181+
When the Lp norm is zero (i.e., all elements along the axis are zero),
2182+
the output is defined to be zero to avoid division by zero.
21802183

21812184
#### Version
21822185

@@ -27115,6 +27118,9 @@ This version of the operator has been available since version 22 of the default
2711527118
### <a name="LpNormalization-22"></a>**LpNormalization-22**</a>
2711627119

2711727120
Given a matrix, apply Lp-normalization along the provided axis.
27121+
The output is computed as: `output = input / Lp_norm(input, axis)`.
27122+
When the Lp norm is zero (i.e., all elements along the axis are zero),
27123+
the output is defined to be zero to avoid division by zero.
2711827124

2711927125
#### Version
2712027126

docs/Operators.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18187,6 +18187,9 @@ expect(
1818718187
### <a name="LpNormalization"></a><a name="lpnormalization">**LpNormalization**</a>
1818818188

1818918189
Given a matrix, apply Lp-normalization along the provided axis.
18190+
The output is computed as: `output = input / Lp_norm(input, axis)`.
18191+
When the Lp norm is zero (i.e., all elements along the axis are zero),
18192+
the output is defined to be zero to avoid division by zero.
1819018193

1819118194
#### Version
1819218195

@@ -18307,7 +18310,8 @@ x = np.array(
1830718310
dtype=np.float32,
1830818311
)
1830918312
l2_norm_axis_0 = np.sqrt(np.sum(x**2, axis=0, keepdims=True))
18310-
y = x / l2_norm_axis_0
18313+
# When norm is 0, output is 0 (0/0 = 0)
18314+
y = np.where(l2_norm_axis_0 == 0, 0, x / l2_norm_axis_0)
1831118315
expect(node, inputs=[x], outputs=[y], name="test_l2normalization_axis_0")
1831218316
```
1831318317

docs/TestCoverage.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13004,7 +13004,8 @@ x = np.array(
1300413004
dtype=np.float32,
1300513005
)
1300613006
l2_norm_axis_0 = np.sqrt(np.sum(x**2, axis=0, keepdims=True))
13007-
y = x / l2_norm_axis_0
13007+
# When norm is 0, output is 0 (0/0 = 0)
13008+
y = np.where(l2_norm_axis_0 == 0, 0, x / l2_norm_axis_0)
1300813009
expect(node, inputs=[x], outputs=[y], name="test_l2normalization_axis_0")
1300913010
```
1301013011

Binary file not shown.

0 commit comments

Comments
 (0)