• [pytorch] API总结、速查


    torch.numel(input) → int

    Returns the total number of elements in the input tensor. Document

    torch.from_numpy(ndarray) → Tensor

    Creates a Tensor from a numpy.ndarray.

    torch.range(start=0, end, step=1, *, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) → Tensor

    torch.range(1, 4) -> tensor([ 1., 2., 3., 4.])

    torch.heaviside(input, values, *, out=None) → Tensor

    >>> values = torch.tensor([0.5])
    >>> torch.heaviside(input, values)
    tensor([0.0000, 0.5000, 1.0000])
    >>> values = torch.tensor([1.2, -2.0, 3.5])
    >>> torch.heaviside(input, values)
    tensor([0., -2., 1.])
    

    torch.cat

    torch.chunk

    torch.stack

    torch.gather

    torch.index_select

    torch.masked_select

    torch.narrow(input, dim, start, length) → Tensor

    torch.split(tensor, split_size_or_sections, dim=0)

    torch.t

    torch.take(input, index)

    torch.transpose(input, dim0, dim1)

    torch.unbind(input, dim=0)

    torch.unsqueeze(input, dim)

    torch.where(condition, x, y) → Tensor

    >>> x = torch.randn(3, 2)
    >>> y = torch.ones(3, 2)
    >>> x
    tensor([[-0.4620,  0.3139],
            [ 0.3898, -0.7197],
            [ 0.0478, -0.1657]])
    >>> torch.where(x > 0, x, y)
    tensor([[ 1.0000,  0.3139],
            [ 0.3898,  1.0000],
            [ 0.0478,  1.0000]])
    >>> x = torch.randn(2, 2, dtype=torch.double)
    >>> x
    tensor([[ 1.0779,  0.0383],
            [-0.8785, -1.1089]], dtype=torch.float64)
    >>> torch.where(x > 0, x, 0.)
    tensor([[1.0779, 0.0383],
            [0.0000, 0.0000]], dtype=torch.float64)
    

    数学运算

    abs/absolute | acos/arccos | add | bitwise_not | bitwise_and | bitwise_or | bitwise_xor | ceil | clamp/clip | div/divide | exp
    | trunk/fix | floor | fmod | logical_and/logical_or/logical_xor | mul/multiply | lerp | neg/negative | pow | round | sign | sqrt |...

    其他

    随机数生成器

  • 相关阅读:
    学会数据库读写分离、分表分库
    MySql数据主从同步配置
    数据库事务的四大特性以及事务的隔离级别
    tensor维度变换
    本地存储,序列化与反序列化
    连连看项目实战之四(异步加载进度条)
    连连看项目实战之二(礼盒动画)
    连连看项目实战之三(解析配置表)
    连连看项目实战之一(搭建场景)
    设计模式(C#)——12责任链模式
  • 原文地址:https://www.cnblogs.com/geoli/p/14223122.html
Copyright © 2020-2023  润新知