ai.onnx.ml - Binarizer¶
Binarizer - 1 (ai.onnx.ml)¶
Version¶
name: Binarizer (GitHub)
domain:
ai.onnx.ml
since_version:
1
function:
False
support_level:
SupportType.COMMON
shape inference:
True
This version of the operator has been available since version 1 of domain ai.onnx.ml.
Summary¶
Maps the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.
Attributes¶
threshold - FLOAT (default is
'0.0'
):Values greater than this are mapped to 1, others to 0.
Inputs¶
X (heterogeneous) - T:
Data to be binarized
Outputs¶
Y (heterogeneous) - T:
Binarized output data
Type Constraints¶
T in (
tensor(double)
,tensor(float)
,tensor(int32)
,tensor(int64)
):The input must be a tensor of a numeric type. The output will be of the same tensor type.
Examples¶
default¶
import numpy as np
import onnx
threshold = 1.0
node = onnx.helper.make_node(
"Binarizer",
inputs=["X"],
outputs=["Y"],
threshold=threshold,
domain="ai.onnx.ml",
)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = compute_binarizer(x, threshold)[0]
expect(node, inputs=[x], outputs=[y], name="test_ai_onnx_ml_binarizer")