API 参考 detrium.nn.decoders.utils detrium.nn.decoders.utils DEIM: DETR with Improved Matching for Fast Convergence
Copyright (c) 2024 The DEIM Authors. All Rights Reserved.
---------------------------------------------------------------------------------
Modified from D-FINE (https://github.com/Peterande/D-FINE)
Copyright (c) 2023 . All Rights Reserved.
inverse_sigmoid(x: torch.Tensor, eps: float=1e-05) -> torch.Tensor名称 类型 默认值 xtorch.Tensor—epsfloat1e-05
bias_init_with_prob(prior_prob=0.01)initialize conv/fc bias value according to a given probability value.
deformable_attention_core_func(value, value_spatial_shapes, sampling_locations, attention_weights)Args:
value (Tensor): [bs, value_length, n_head, c]
value_spatial_shapes (Tensor|List): [n_levels, 2]
value_level_start_index (Tensor|List): [n_levels]
sampling_locations (Tensor): [bs, query_length, n_head, n_levels, n_points, 2]
attention_weights (Tensor): [bs, query_length, n_head, n_levels, n_points]
Returns:
output (Tensor): [bs, Length_{query}, C]
名称 类型 默认值 value——value_spatial_shapes——sampling_locations——attention_weights——
deformable_attention_core_func_v2(value: torch.Tensor, value_spatial_shapes, sampling_locations: torch.Tensor, attention_weights: torch.Tensor, num_points_list: List[int], method='default', value_shape='default')Args:
value (Tensor): [bs, value_length, n_head, c]
value_spatial_shapes (Tensor|List): [n_levels, 2]
value_level_start_index (Tensor|List): [n_levels]
sampling_locations (Tensor): [bs, query_length, n_head, n_levels * n_points, 2]
attention_weights (Tensor): [bs, query_length, n_head, n_levels * n_points]
Returns:
output (Tensor): [bs, Length_{query}, C]
名称 类型 默认值 valuetorch.Tensor—value_spatial_shapes——sampling_locationstorch.Tensor—attention_weightstorch.Tensor—num_points_listList[int]—method—'default'value_shape—'default'
get_activation(act: str, inpace: bool=True)get activation
名称 类型 默认值 actstr—inpaceboolTrue
self_attn_needs_weights(tensor: torch.Tensor) -> boolReturn True for ONNX export or FP32 execution (exact parity), False under FP16/BF16 AMP.
名称 类型 默认值 tensortorch.Tensor—