pytorch常用函数

1.torch.max(inputdimkeepdim=False*out=None)

返回一个命名元组,其中是给定维度中张量 每一行的最大值。并且是找到的每个最大值的索引位置 (argmax)。(values, indices)valuesinputdimindices

如果keepdim为True,则输出张量与输入张量的大小相同,但维度dim中的输出张量大小为1。否则,dim会被压缩(请参见torch.squege()),导致输出张量的维度比输入张量少1。

2.torch.permute(inputdims) → Tensor

返回原始张量输入的视图,其维度已置换。

>>> x = torch.randn(2, 3, 5)
>>> x.size()
torch.Size([2, 3, 5])
>>> torch.permute(x, (2, 0, 1)).size()
torch.Size([5, 2, 3])

3.Tensor.contiguous(memory_format=torch.contiguous_format

返回张量的所需内存格式。默认值:torch.continuous_format。 

返回包含与自张量相同数据的连续内存张量。如果自张量已处于指定的内存格式,则此函数返回自张量。

2.torch.nn.Module

extra_repr()
方法: extra_repr()
    Set the extra representation of the module
    设置模块的额外表示信息.
    To print customized extra information, you should reimplement 
    this method in your own modules. Both single-line and multi-line 
    strings are acceptable.
    为了能够打印用户定制化的额外信息,你需要在你的神经网络模块中重新实现这
    个方法. 单行字符串或多行字符串都可以用在这个函数中.
 

你可能感兴趣的:(pytorch,pytorch,深度学习,人工智能)