ai.onnx.ml - Binarizer

Binarizer - 1 (ai.onnx.ml)

版本

  • 名称: Binarizer (GitHub)

  • : ai.onnx.ml

  • 起始版本: 1

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

此版本运算符自 ai.onnx.ml 域的第 1 版起可用。

摘要

根据与阈值的比较结果,将输入张量的值逐元素映射为 0 或 1。

属性

  • threshold - FLOAT(默认值为 '0.0'

    大于此值的值映射为 1,其他值映射为 0。

输入

  • X (异构) - T

    待二值化的数据

输出

  • Y (异构) - T

    二值化输出数据

类型约束

  • T in ( 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")