ai.onnx.ml - Binarizer¶
Binarizer - 1 (ai.onnx.ml)¶
版本¶
網域:
ai.onnx.ml
since_version:
1
函式:
False
支援層級:
SupportType.COMMON
形狀推斷:
True
此版本的運算子自網域 ai.onnx.ml 的版本 1 開始提供。
摘要¶
根據與閾值比較的結果,將輸入張量的值逐元素對應至 0 或 1。
屬性¶
threshold - FLOAT (預設值為
'0.0'
)大於此值的值會對應至 1,其他值則對應至 0。
輸入¶
X (異質) - T
要二元化的資料
輸出¶
Y (異質) - T
二元化輸出資料
類型約束¶
T 在 (
tensor(double)
,tensor(float)
,tensor(int32)
,tensor(int64)
)輸入必須是數值類型的張量。輸出將會是相同的張量類型。
範例¶
預設值¶
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")