ISubGVQA.utils.misc

Misc functions, including distributed helpers.

Mostly copy-paste from torchvision references.

Classes

SmoothedValue

Track a series of values and provide access to smoothed values over a

MetricLogger

NestedTensor

Functions

all_gather(data)

Run all_gather on arbitrary picklable data (not necessarily tensors)

reduce_dict(input_dict[, average])

Args:

get_sha()

collate_fn(batch)

_max_by_axis(→ List[int])

nested_tensor_from_tensor_list(tensor_list)

setup_for_distributed(is_master)

This function disables printing when not in master process

is_dist_avail_and_initialized()

get_world_size()

get_rank()

is_main_process()

save_on_master(*args, **kwargs)

init_distributed_mode(args)

accuracy(output, target[, topk])

Computes the precision@k for the specified values of k

interpolate(→ torch.Tensor)

Equivalent to nn.functional.interpolate, but with support for empty batch sizes.

Module Contents

class ISubGVQA.utils.misc.SmoothedValue(window_size=20, fmt=None)

Bases: object

Track a series of values and provide access to smoothed values over a window or the global series average.

deque
total = 0.0
count = 0
fmt = None
update(value, n=1)
synchronize_between_processes()

Warning: does not synchronize the deque!

property median
property avg
property global_avg
property max
property value
__str__()
ISubGVQA.utils.misc.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

ISubGVQA.utils.misc.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.

class ISubGVQA.utils.misc.MetricLogger(delimiter='\t')

Bases: object

meters
delimiter = '\t'
update(**kwargs)
__getattr__(attr)
__str__()
synchronize_between_processes()
add_meter(name, meter)
log_every(iterable, print_freq, header=None)
ISubGVQA.utils.misc.get_sha()
ISubGVQA.utils.misc.collate_fn(batch)
ISubGVQA.utils.misc._max_by_axis(the_list: List[List[int]]) List[int]
ISubGVQA.utils.misc.nested_tensor_from_tensor_list(tensor_list: List[torch.Tensor])
class ISubGVQA.utils.misc.NestedTensor(tensors, mask: torch.Tensor | None)

Bases: object

tensors
mask
to(device: Device) NestedTensor
decompose()
__repr__()
ISubGVQA.utils.misc.setup_for_distributed(is_master)

This function disables printing when not in master process

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(*args, **kwargs)
ISubGVQA.utils.misc.init_distributed_mode(args)
ISubGVQA.utils.misc.accuracy(output, target, topk=(1,))

Computes the precision@k for the specified values of k

ISubGVQA.utils.misc.interpolate(input: torch.Tensor, size: List[int] | None = None, scale_factor: float | None = None, mode: str = 'nearest', align_corners: bool | None = 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.