Pytorch

来自Shiyin's note
Shen讨论 | 贡献2021年10月17日 (日) 08:26的版本
跳到导航 跳到搜索

网络初始化

  • Xavier and Kaiming initialization [4]

函数

  • torch.clamp(input, min=None, max=None, *, out=None) → Tensor
Clamps all elements in input into the range [ min, max ]. Letting min_value and max_value be min and max, respectively
  • torch.eye(n, m=None, out=None)
返回一个2维张量,对角线位置全1,其它位置全0

Tensor

  • cpu() numpy() detach() item() [5]
注意cuda上面的变量类型只能是tensor,不能是其他

torchvision

  • PyTorch框架中有一个非常重要且好用的包:torchvision,该包主要由3个子包组成,分别是:torchvision.datasets、torchvision.models、torchvision.transforms [6]
  • __all__ = ["Compose", "ToTensor", "ToPILImage", "Normalize", "Resize",

"Scale", "CenterCrop", "Pad", "Lambda", "RandomCrop", "RandomHorizontalFlip", "RandomVerticalFlip", "RandomResizedCrop", "RandomSizedCrop", "FiveCrop", "TenCrop","LinearTransformation", "ColorJitter", "RandomRotation", "Grayscale", "RandomGrayscale"]