MCPcopy Create free account
hub / github.com/MCG-NJU/VideoMAE / tensor_normalize

Function tensor_normalize

kinetics.py:355–372  ·  view source on GitHub ↗

Normalize a given tensor by subtracting the mean and dividing the std. Args: tensor (tensor): tensor to normalize. mean (tensor or list): mean value to subtract. std (tensor or list): std to divide.

(tensor, mean, std)

Source from the content-addressed store, hash-verified

353
354
355def tensor_normalize(tensor, mean, std):
356 """
357 Normalize a given tensor by subtracting the mean and dividing the std.
358 Args:
359 tensor (tensor): tensor to normalize.
360 mean (tensor or list): mean value to subtract.
361 std (tensor or list): std to divide.
362 """
363 if tensor.dtype == torch.uint8:
364 tensor = tensor.float()
365 tensor = tensor / 255.0
366 if type(mean) == list:
367 mean = torch.tensor(mean)
368 if type(std) == list:
369 std = torch.tensor(std)
370 tensor = tensor - mean
371 tensor = tensor / std
372 return tensor
373
374
375class VideoMAE(torch.utils.data.Dataset):

Callers 1

_aug_frameMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected