ISubGVQA.utils.misc =================== .. py:module:: ISubGVQA.utils.misc .. autoapi-nested-parse:: Misc functions, including distributed helpers. Mostly copy-paste from torchvision references. Classes ------- .. autoapisummary:: ISubGVQA.utils.misc.SmoothedValue ISubGVQA.utils.misc.MetricLogger ISubGVQA.utils.misc.NestedTensor Functions --------- .. autoapisummary:: ISubGVQA.utils.misc.all_gather ISubGVQA.utils.misc.reduce_dict ISubGVQA.utils.misc.get_sha ISubGVQA.utils.misc.collate_fn ISubGVQA.utils.misc._max_by_axis ISubGVQA.utils.misc.nested_tensor_from_tensor_list ISubGVQA.utils.misc.setup_for_distributed ISubGVQA.utils.misc.is_dist_avail_and_initialized ISubGVQA.utils.misc.get_world_size ISubGVQA.utils.misc.get_rank ISubGVQA.utils.misc.is_main_process ISubGVQA.utils.misc.save_on_master ISubGVQA.utils.misc.init_distributed_mode ISubGVQA.utils.misc.accuracy ISubGVQA.utils.misc.interpolate Module Contents --------------- .. py:class:: SmoothedValue(window_size=20, fmt=None) Bases: :py:obj:`object` Track a series of values and provide access to smoothed values over a window or the global series average. .. py:attribute:: deque .. py:attribute:: total :value: 0.0 .. py:attribute:: count :value: 0 .. py:attribute:: fmt :value: None .. py:method:: update(value, n=1) .. py:method:: synchronize_between_processes() Warning: does not synchronize the deque! .. py:property:: median .. py:property:: avg .. py:property:: global_avg .. py:property:: max .. py:property:: value .. py:method:: __str__() .. py:function:: all_gather(data) Run all_gather on arbitrary picklable data (not necessarily tensors) Args: data: any picklable object Returns: list[data]: list of data gathered from each rank .. py:function:: reduce_dict(input_dict, average=True) Args: input_dict (dict): all the values will be reduced average (bool): whether to do average or sum Reduce the values in the dictionary from all processes so that all processes have the averaged results. Returns a dict with the same fields as input_dict, after reduction. .. py:class:: MetricLogger(delimiter='\t') Bases: :py:obj:`object` .. py:attribute:: meters .. py:attribute:: delimiter :value: '\t' .. py:method:: update(**kwargs) .. py:method:: __getattr__(attr) .. py:method:: __str__() .. py:method:: synchronize_between_processes() .. py:method:: add_meter(name, meter) .. py:method:: log_every(iterable, print_freq, header=None) .. py:function:: get_sha() .. py:function:: collate_fn(batch) .. py:function:: _max_by_axis(the_list: List[List[int]]) -> List[int] .. py:function:: nested_tensor_from_tensor_list(tensor_list: List[torch.Tensor]) .. py:class:: NestedTensor(tensors, mask: Optional[torch.Tensor]) Bases: :py:obj:`object` .. py:attribute:: tensors .. py:attribute:: mask .. py:method:: to(device: Device) -> NestedTensor .. py:method:: decompose() .. py:method:: __repr__() .. py:function:: setup_for_distributed(is_master) This function disables printing when not in master process .. py:function:: is_dist_avail_and_initialized() .. py:function:: get_world_size() .. py:function:: get_rank() .. py:function:: is_main_process() .. py:function:: save_on_master(*args, **kwargs) .. py:function:: init_distributed_mode(args) .. py:function:: accuracy(output, target, topk=(1, )) Computes the precision@k for the specified values of k .. py:function:: interpolate(input: torch.Tensor, size: Optional[List[int]] = None, scale_factor: Optional[float] = None, mode: str = 'nearest', align_corners: Optional[bool] = None) -> torch.Tensor Equivalent to nn.functional.interpolate, but with support for empty batch sizes. This will eventually be supported natively by PyTorch, and this class can go away.