"Only list and tensor are supported as derivation targets."
)
def_node_selection(
pred:torch.Tensor,
output_node:int,
selected_output_node:int,
eval_max_output_node_only:bool,
)->torch.Tensor:
"""Method to select the nodes for which the taylorcoefficients should be computed.
...
...
@@ -110,7 +77,7 @@ def _node_selection(
Args:
pred (torch.Tensor): X data of shape (batch, features).
output_node (Optional[Int]): Node selection for evaluation. If None, all nodes are selected. If int, only the selected node is selected. If tuple, only the selected nodes are selected.
eval_max_output_node_only (Bool): If True, only the node with the highest value is selected.
eval_max_selected_output_node_only (Bool): If True, only the node with the highest value is selected.
"""Function to handle multiple indices and return the taylorcoefficients as a dictionary: to be used by the user.
Args:
key_to_tctensor (str): Key to input tensor in forward_kwargs. Based on this tensor the taylorcoefficients are computed.
forward_kwargs_tctensor_key (str): Key to input tensor in forward_kwargs. Based on this tensor the taylorcoefficients are computed.
forward_kwargs (Union[None, Dict[str, Any]]): Dictionary with forward arguments
idx_list (List[Tuple[int, ...]]): List of indices for which the taylorcoefficients should be computed.
output_node (Int, optional): Node selection for evaluation. Defaults to None.
tc_idx_list (List[Tuple[int, ...]]): List of indices for which the taylorcoefficients should be computed based on the tensor selected by forward_kwargs_tctensor_key (and additional_idx_to_tctensor).
selected_output_node (Int, optional): Node selection for evaluation. Defaults to None.
eval_max_output_node_only (Bool, optional): If True, only the node with the highest value is selected. Defaults to True.
reduce_func (Callable, optional): Function to reduce the taylorcoefficients. Defaults to identity.
features_axis (int, optional): Dimension containing features in tensor forward_kwargs.tctensor. Defaults to -1.
idx_to_tctensor (Union[int, None], optional): Index of the target tensor if forward_kwargs[key_to_tctensor] is a list. Defaults to None.
keep_model_output_idx (int, optional): Index of the model output if its output is a sequence. Defaults to 0.
tctensor_features_axis (int, optional): Dimension containing features in tctensor given in forward_kwargs. Defaults to -1.
additional_idx_to_tctensor (int, optional): Index of the tctensor if forward_kwargs[forward_kwargs_tctensor_key] is a list. Defaults to None.
selected_model_output_idx (int, optional): Index of the model output if its output is a sequence. Defaults to 0.
Raises:
ValueError: idx_list must be a List of tuples!
ValueError: tc_idx_list must be a List of tuples!
Returns:
Dict: Dictionary with taylorcoefficients. Values are set by the user within the reduce function. Keys are the indices (tuple).