当前位置: 首页>>代码示例>>Python>>正文


Python torch._tensor_classes方法代码示例

本文整理汇总了Python中torch._tensor_classes方法的典型用法代码示例。如果您正苦于以下问题:Python torch._tensor_classes方法的具体用法?Python torch._tensor_classes怎么用?Python torch._tensor_classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torch的用法示例。


在下文中一共展示了torch._tensor_classes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_print

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def test_print(self):
        for t in torch._tensor_classes:
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100, 100).fill_(1)
            obj.__repr__()
            str(obj)
        for t in torch._storage_classes:
            if  t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100).fill_(1)
            obj.__repr__()
            str(obj)

        x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
        x.__repr__()
        str(x) 
开发者ID:apaszke,项目名称:pytorch-dist,代码行数:19,代码来源:test_torch.py

示例2: test_print

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def test_print(self):
        for t in torch._tensor_classes:
            if t in torch.sparse._sparse_tensor_classes:
                continue
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100, 100).fill_(1)
            obj.__repr__()
            str(obj)
        for t in torch._storage_classes:
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100).fill_(1)
            obj.__repr__()
            str(obj)

        x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
        x.__repr__()
        str(x) 
开发者ID:tylergenter,项目名称:pytorch,代码行数:21,代码来源:test_torch.py

示例3: test_print

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def test_print(self):
        for t in torch._tensor_classes:
            if t == torch.HalfTensor:
                continue  # HalfTensor does not support fill
            if t in torch.sparse._sparse_tensor_classes:
                continue
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100, 100).fill_(1)
            obj.__repr__()
            str(obj)
        for t in torch._storage_classes:
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100).fill_(1)
            obj.__repr__()
            str(obj)

        x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
        x.__repr__()
        str(x) 
开发者ID:ezyang,项目名称:pytorch,代码行数:23,代码来源:test_torch.py

示例4: __init__

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def __init__(self, context=None, reducers=None):
        if context is None:
            context = multiprocessing
        if reducers is None:
            reducers = {}

        for t in torch._tensor_classes:
            reducers.setdefault(t, reduce_tensor)
        for t in torch._storage_classes:
            reducers.setdefault(t, reduce_storage)

        super(Queue, self).__init__(context, reducers) 
开发者ID:apaszke,项目名称:pytorch-dist,代码行数:14,代码来源:queue.py

示例5: init_reductions

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def init_reductions():
    ForkingPickler.register(torch.cuda.Event, reduce_event)

    for t in torch._storage_classes:
        ForkingPickler.register(t, reduce_storage)

    for t in torch._tensor_classes:
        ForkingPickler.register(t, reduce_tensor) 
开发者ID:tylergenter,项目名称:pytorch,代码行数:10,代码来源:reductions.py

示例6: test_print

# 需要导入模块: import torch [as 别名]
# 或者: from torch import _tensor_classes [as 别名]
def test_print(self):
        for t in torch._tensor_classes:
            if IS_WINDOWS and t in [torch.cuda.sparse.HalfTensor, torch.cuda.HalfTensor]:
                return  # CUDA HalfTensor is not supported on Windows yet
            if t == torch.HalfTensor:
                continue  # HalfTensor does not support fill
            if t in torch.sparse._sparse_tensor_classes:
                continue
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100, 100).fill_(1)
            obj.__repr__()
            str(obj)
        for t in torch._storage_classes:
            if t.is_cuda and not torch.cuda.is_available():
                continue
            obj = t(100).fill_(1)
            obj.__repr__()
            str(obj)

        x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
        x.__repr__()
        str(x)

        x = torch.DoubleTensor([1e-324, 1e-323, 1e-322, 1e307, 1e308, 1e309])
        x.__repr__()
        str(x), 
开发者ID:pytorch,项目名称:pytorch,代码行数:29,代码来源:test_torch.py


注:本文中的torch._tensor_classes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。