MCPcopy Create free account
hub / github.com/OpenGVLab/UniFormerV2 / revert_tensor_normalize

Function revert_tensor_normalize

slowfast/datasets/utils.py:383–397  ·  view source on GitHub ↗

Revert normalization for a given tensor by multiplying by the std and adding the mean. Args: tensor (tensor): tensor to revert normalization. mean (tensor or list): mean value to add. std (tensor or list): std to multiply.

(tensor, mean, std)

Source from the content-addressed store, hash-verified

381
382
383def revert_tensor_normalize(tensor, mean, std):
384 """
385 Revert normalization for a given tensor by multiplying by the std and adding the mean.
386 Args:
387 tensor (tensor): tensor to revert normalization.
388 mean (tensor or list): mean value to add.
389 std (tensor or list): std to multiply.
390 """
391 if type(mean) == list:
392 mean = torch.tensor(mean)
393 if type(std) == list:
394 std = torch.tensor(std)
395 tensor = tensor * std
396 tensor = tensor + mean
397 return tensor
398
399
400def create_sampler(dataset, shuffle, cfg):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected