ParametricReLU¶
在输入张量 A 上应用参数化 ReLU 函数,并生成一个具有相同维度的输出张量 B。参数化 ReLU 函数是一个 Leaky ReLU,其中 \(x<0\) 的斜率可以为每个元素定义。
输入¶
input: T
类型的张量。
slopes: T
类型的张量。
输出¶
output: T
类型的张量。
数据类型¶
T: int8
, float16
, float32
, bfloat16
形状信息¶
input 和 output 是形状为 \([a_0,...,a_n]\) 的张量。
slopes 是形状为 \([b_0,...,b_n]\) 的张量,其中 \(b_i=a_i\) 或 \(b_i=1\)。
体积限制¶
input 和 slopes 最多可以有 \(2^{31}-1\) 个元素。
DLA 支持¶
支持 DLA FP16 和 DLA INT8。
当在 DLA 上运行此层时,slopes 输入必须是构建时常量。
示例¶
ParametricReLU
in1 = network.add_input("input1", dtype=trt.float32, shape=(2, 3))
slopes = network.add_input("slopes", dtype=trt.float32, shape=(2, 3))
layer = network.add_parametric_relu(in1, slopes)
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array([[-3.0, -2.0, -1.0], [0.0, 1.0, 2.0]])
inputs[slopes.name] = np.array([[-1.0, 1.0, 0.0], [0.0, 1.0, 2.0]])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array([[3.0, -2.0, 0.0], [0.0, 1.0, 2.0]])
带广播的 ParametricReLU
in1 = network.add_input("input1", dtype=trt.float32, shape=(2, 3))
slopes = network.add_input("slopes", dtype=trt.float32, shape=(2, 1))
layer = network.add_parametric_relu(in1, slopes)
network.mark_output(layer.get_output(0))
inputs[in1.name] = np.array([[-3.0, -2.0, -1.0], [0.0, 1.0, 2.0]])
inputs[slopes.name] = np.array([[2.0], [1.0]])
outputs[layer.get_output(0).name] = layer.get_output(0).shape
expected[layer.get_output(0).name] = np.array([[-6.0, -4.0, -2.0], [0.0, 1.0, 2.0]])
C++ API¶
有关 C++ IParametricReLULayer 运算符的更多信息,请参阅 C++ IParametricReLULayer 文档。
Python API¶
有关 Python IParametricReLULayer 运算符的更多信息,请参阅 Python IParametricReLULayer 文档。