code
stringlengths
1
1.05M
repo_name
stringlengths
7
65
path
stringlengths
2
255
language
stringclasses
236 values
license
stringclasses
24 values
size
int64
1
1.05M
import torch._C as _C TensorProtoDataType = _C._onnx.TensorProtoDataType OperatorExportTypes = _C._onnx.OperatorExportTypes PYTORCH_ONNX_CAFFE2_BUNDLE = _C._onnx.PYTORCH_ONNX_CAFFE2_BUNDLE ONNX_ARCHIVE_MODEL_PROTO_NAME = "__MODEL_PROTO" # TODO: Update these variables when there # is a new ir_version and producer_ver...
rt65/pytorch
torch/onnx/__init__.py
Python
bsd
9,803
r"""This file provides a location for operators that help exporting models via onnx. E.g. shape_as_tensor and reshape_from_tensor_shape are to make all dynamic sizes operations traceble. NOTE: at one point these functions were implemented differently. Since then we have implemented these directly in ATen, so this file...
rt65/pytorch
torch/onnx/operators.py
Python
bsd
578
from __future__ import absolute_import, division, print_function, unicode_literals import torch from torch._C import ListType import warnings import torch.onnx # This import monkey-patches graph manipulation methods on Graph, used for the # ONNX symbolics import torch.onnx.utils from functools import wraps # Note ...
rt65/pytorch
torch/onnx/symbolic_helper.py
Python
bsd
13,136
from __future__ import absolute_import, division, print_function, unicode_literals import torch from torch.nn.modules.utils import _single, _pair, _triple import torch.onnx # This import monkey-patches graph manipulation methods on Graph, used for the # ONNX symbolics import torch.onnx.utils import torch.onnx.symboli...
rt65/pytorch
torch/onnx/symbolic_opset10.py
Python
bsd
8,635
from __future__ import absolute_import, division, print_function, unicode_literals import torch import torch.onnx.symbolic_helper as sym_help from torch.onnx.symbolic_helper import parse_args, _unimplemented from torch.onnx.symbolic_helper import _black_list_in_opset # EDITING THIS FILE? READ THIS FIRST! # see Note...
rt65/pytorch
torch/onnx/symbolic_opset11.py
Python
bsd
5,081
from torch.onnx.symbolic_helper import _black_list_in_opset import torch.onnx.symbolic_opset9 as sym_opset9 import warnings # Note [ONNX operators that are added/updated from opset 7 to opset 8] # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # New operators: # Expand # # Updated operators:...
rt65/pytorch
torch/onnx/symbolic_opset7.py
Python
bsd
1,805
from __future__ import absolute_import, division, print_function, unicode_literals import torch import torch.onnx.symbolic_helper as sym_help import torch.onnx.symbolic_opset9 as sym_opset9 from torch.onnx.symbolic_helper import parse_args, _unimplemented, _black_list_in_opset, _try_get_scalar_type from torch.onnx.sy...
rt65/pytorch
torch/onnx/symbolic_opset8.py
Python
bsd
10,107
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import torch from torch._C import ListType, OptionalType from torch.nn.modules.utils import _single, _pair, _triple import torch.onnx # This import monkey-patches graph ...
rt65/pytorch
torch/onnx/symbolic_opset9.py
Python
bsd
78,316
import warnings import importlib from inspect import getmembers, isfunction # The symbolic registry "_registry" is a dictionary that maps operators # (for a specific domain and opset version) to their symbolic functions. # An operator is defined by its domain, opset version, and opname. # The keys are tuples (domain, ...
rt65/pytorch
torch/onnx/symbolic_registry.py
Python
bsd
3,773
from __future__ import absolute_import, division, print_function, unicode_literals r""" The torch.onnx module contains functions to export models into the ONNX IR format. These models can be loaded with the ONNX library and then converted to models which run on other deep learning frameworks. """ import torch import...
rt65/pytorch
torch/onnx/utils.py
Python
bsd
36,554
""" :mod:`torch.optim` is a package implementing various optimization algorithms. Most commonly used methods are already supported, and the interface is general enough, so that more sophisticated ones can be also easily integrated in the future. """ from .adadelta import Adadelta # noqa: F401 from .adagrad import Ada...
rt65/pytorch
torch/optim/__init__.py
Python
bsd
922
from .sgd import SGD as SGD from .adam import Adam as Adam from . import lr_scheduler as lr_scheduler
rt65/pytorch
torch/optim/__init__.pyi
Python
bsd
102
import torch from .optimizer import Optimizer class Adadelta(Optimizer): """Implements Adadelta algorithm. It has been proposed in `ADADELTA: An Adaptive Learning Rate Method`__. Arguments: params (iterable): iterable of parameters to optimize or dicts defining parameter groups ...
rt65/pytorch
torch/optim/adadelta.py
Python
bsd
2,948
import torch from .optimizer import Optimizer class Adagrad(Optimizer): """Implements Adagrad algorithm. It has been proposed in `Adaptive Subgradient Methods for Online Learning and Stochastic Optimization`_. Arguments: params (iterable): iterable of parameters to optimize or dicts defining...
rt65/pytorch
torch/optim/adagrad.py
Python
bsd
4,143
import math import torch from .optimizer import Optimizer class Adam(Optimizer): r"""Implements Adam algorithm. It has been proposed in `Adam: A Method for Stochastic Optimization`_. Arguments: params (iterable): iterable of parameters to optimize or dicts defining parameter groups ...
rt65/pytorch
torch/optim/adam.py
Python
bsd
4,652
from typing import Tuple from .optimizer import _params_t, Optimizer class Adam(Optimizer): def __init__(self, params: _params_t, lr: float=..., betas: Tuple[float, float]=..., eps: float=..., weight_decay: float=..., amsgrad: bool = ...) -> None: ...
rt65/pytorch
torch/optim/adam.pyi
Python
bsd
257
import torch from .optimizer import Optimizer class Adamax(Optimizer): """Implements Adamax algorithm (a variant of Adam based on infinity norm). It has been proposed in `Adam: A Method for Stochastic Optimization`__. Arguments: params (iterable): iterable of parameters to optimize or dicts defi...
rt65/pytorch
torch/optim/adamax.py
Python
bsd
3,425
import math import torch from .optimizer import Optimizer class AdamW(Optimizer): r"""Implements AdamW algorithm. The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. The AdamW variant was proposed in `Decoupled Weight Decay Regularization`_. Arguments: ...
rt65/pytorch
torch/optim/adamw.py
Python
bsd
4,898
import math import torch from .optimizer import Optimizer class ASGD(Optimizer): """Implements Averaged Stochastic Gradient Descent. It has been proposed in `Acceleration of stochastic approximation by averaging`_. Arguments: params (iterable): iterable of parameters to optimize or dicts def...
rt65/pytorch
torch/optim/asgd.py
Python
bsd
3,025
import torch from functools import reduce from .optimizer import Optimizer def _cubic_interpolate(x1, f1, g1, x2, f2, g2, bounds=None): # ported from https://github.com/torch/optim/blob/master/polyinterp.lua # Compute bounds of interpolation area if bounds is not None: xmin_bound, xmax_bound = bou...
rt65/pytorch
torch/optim/lbfgs.py
Python
bsd
16,764
import types import math from torch._six import inf from functools import wraps import warnings import weakref from bisect import bisect_right from .optimizer import Optimizer class _LRScheduler(object): def __init__(self, optimizer, last_epoch=-1): if not isinstance(optimizer, Optimizer): ra...
rt65/pytorch
torch/optim/lr_scheduler.py
Python
bsd
43,910
from typing import Iterable, Any, Optional, Callable from .optimizer import Optimizer class _LRScheduler: def __init__(self, optimizer: Optimizer, last_epoch: int=...) -> None: ... def state_dict(self) -> dict: ... def load_state_dict(self, state_dict: dict) -> None: ... def get_lr(self) -> float: ... ...
rt65/pytorch
torch/optim/lr_scheduler.pyi
Python
bsd
2,136
from collections import defaultdict from torch._six import container_abcs import torch from copy import deepcopy from itertools import chain class _RequiredParameter(object): """Singleton class representing a required parameter for an Optimizer.""" def __repr__(self): return "<required parameter>" r...
rt65/pytorch
torch/optim/optimizer.py
Python
bsd
8,724
from typing import Iterable, Union, Callable, Optional from .. import Tensor _params_t = Union[Iterable[Tensor], Iterable[dict]] class Optimizer: def __init__(self, params: _params_t) -> None: ... def state_dict(self) -> dict: ... def load_state_dict(self, state_dict: dict) -> None: ... def zero_grad(...
rt65/pytorch
torch/optim/optimizer.pyi
Python
bsd
477
import torch from .optimizer import Optimizer class RMSprop(Optimizer): r"""Implements RMSprop algorithm. Proposed by G. Hinton in his `course <http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf>`_. The centered version first appears in `Generating Sequences With Recurrent N...
rt65/pytorch
torch/optim/rmsprop.py
Python
bsd
4,463
import torch from .optimizer import Optimizer class Rprop(Optimizer): """Implements the resilient backpropagation algorithm. Arguments: params (iterable): iterable of parameters to optimize or dicts defining parameter groups lr (float, optional): learning rate (default: 1e-2) ...
rt65/pytorch
torch/optim/rprop.py
Python
bsd
2,800
import torch from .optimizer import Optimizer, required class SGD(Optimizer): r"""Implements stochastic gradient descent (optionally with momentum). Nesterov momentum is based on the formula from `On the importance of initialization and momentum in deep learning`__. Args: params (iterable): ...
rt65/pytorch
torch/optim/sgd.py
Python
bsd
4,095
from .optimizer import _params_t, Optimizer class SGD(Optimizer): def __init__(self, params: _params_t, lr: float, momentum: float=..., dampening: float=..., weight_decay:float=..., nesterov:bool=...) -> None: ...
rt65/pytorch
torch/optim/sgd.pyi
Python
bsd
219
import math import torch from .optimizer import Optimizer class SparseAdam(Optimizer): r"""Implements lazy version of Adam algorithm suitable for sparse tensors. In this variant, only moments that show up in the gradient get updated, and only those portions of the gradient get applied to the parameters. ...
rt65/pytorch
torch/optim/sparse_adam.py
Python
bsd
4,595
from __future__ import absolute_import, division, print_function, unicode_literals from collections import namedtuple from .observer import * from .fake_quantize import * import torch.nn as nn class QConfig(namedtuple('QConfig', ['activation', 'weight'])): """ Describes how to quantize a layer or a part of the...
rt65/pytorch
torch/quantization/QConfig.py
Python
bsd
3,208
from __future__ import absolute_import, division, print_function, unicode_literals from .quantize import * # noqa: F401 from .observer import * # noqa: F401 from .QConfig import * # noqa: F401 from .fake_quantize import * # noqa: F401 from .fuse_modules import fuse_modules # noqa: F401 def default_eval_fn(model, ...
rt65/pytorch
torch/quantization/__init__.py
Python
bsd
1,343
from __future__ import absolute_import, division, print_function, unicode_literals import torch from .QConfig import QConfig def _check_is_script_module(model): if not isinstance(model, torch.jit.ScriptModule): raise ValueError('input must be a script module, got: ' + str(type(model))) def prepare_script...
rt65/pytorch
torch/quantization/_quantize_script.py
Python
bsd
1,665
from __future__ import absolute_import, division, print_function, unicode_literals import torch from torch.nn import Module from .observer import MinMaxObserver, _with_args class FakeQuantize(Module): ''' Simulate the quantize and dequantize operations in training time. The output of this module is given by ...
rt65/pytorch
torch/quantization/fake_quantize.py
Python
bsd
5,340
from __future__ import absolute_import, division, print_function, unicode_literals import torch import torch.nn._intrinsic.modules.fused as torch_fused def fuse_conv_bn(conv, bn): r"""Given the conv and bn modules, fuses them and returns the fused module Args: conv: Module instance of type conv2d ...
rt65/pytorch
torch/quantization/fuse_modules.py
Python
bsd
4,295
from __future__ import absolute_import, division, print_function, unicode_literals import math import warnings from abc import ABCMeta, abstractmethod from functools import partial import torch import torch.nn as nn from torch._jit_internal import List, Optional class _PartialWrapper(object): def __init__(self,...
rt65/pytorch
torch/quantization/observer.py
Python
bsd
22,992
from __future__ import absolute_import, division, print_function, unicode_literals import copy import torch import torch.nn as nn import torch.nn._intrinsic as nni import torch.nn._intrinsic.quantized as nniq import torch.nn._intrinsic.qat as nniqat import torch.nn.quantized as nnq import torch.nn.quantized.dynamic as...
rt65/pytorch
torch/quantization/quantize.py
Python
bsd
15,788
import torch class SobolEngine(object): r""" The :class:`torch.quasirandom.SobolEngine` is an engine for generating (scrambled) Sobol sequences. Sobol sequences are an example of low discrepancy quasi-random sequences. This implementation of an engine for Sobol sequences is capable of samplin...
rt65/pytorch
torch/quasirandom.py
Python
bsd
5,061
import contextlib import warnings from torch._C import default_generator def set_rng_state(new_state): r"""Sets the random number generator state. Args: new_state (torch.ByteTensor): The desired state """ default_generator.set_state(new_state) def get_rng_state(): r"""Returns the rando...
rt65/pytorch
torch/random.py
Python
bsd
4,290
#pragma once #include <torch/csrc/api/include/torch/types.h> #include <torch/csrc/autograd/generated/variable_factories.h> #include <torch/csrc/autograd/grad_mode.h> #include <torch/csrc/jit/custom_operator.h> #include <torch/csrc/jit/import.h> #include <torch/csrc/jit/pickle.h> #include <ATen/ATen.h>
rt65/pytorch
torch/script.h
C
bsd
305
import difflib import os import io import shutil import struct import sys import torch import tarfile import tempfile import warnings from contextlib import closing, contextmanager from ._utils import _import_dotted_name from ._six import string_classes as _string_classes from torch._utils_internal import get_source_li...
rt65/pytorch
torch/serialization.py
Python
bsd
25,271
# The Tensor classes are added to this module by python_tensor.cpp import torch __all__ = [ 'addmm', 'mm', 'sum', ] def addmm(mat, mat1, mat2, beta=1, alpha=1): # type: (Tensor, Tensor, Tensor, float, float) -> Tensor r""" This function does exact same thing as :func:`torch.addmm` in the forw...
rt65/pytorch
torch/sparse/__init__.py
Python
bsd
5,433
import io import torch from ._utils import _type, _cuda class _StorageBase(object): is_cuda = False is_sparse = False def __str__(self): content = ' ' + '\n '.join(str(self[i]) for i in range(len(self))) return content + '\n[{} of size {}]'.format(torch.typename(self), len(self)) de...
rt65/pytorch
torch/storage.py
Python
bsd
4,400
import sys import torch import torch._C as _C from torch._namedtensor_internals import update_names, check_serializing_named_tensor, resolve_ellipsis from torch._namedtensor_internals import unzip_namedshape from collections import OrderedDict import torch.utils.hooks as hooks import warnings import weakref from torch....
rt65/pytorch
torch/tensor.py
Python
bsd
21,955
""" The testing package contains testing-specific utilities. """ import torch import random FileCheck = torch._C.FileCheck __all__ = [ 'assert_allclose', 'make_non_contiguous', 'rand_like', 'randn_like' ] rand_like = torch.rand_like randn_like = torch.randn_like def assert_allclose(actual, expected, rtol=None...
rt65/pytorch
torch/testing/__init__.py
Python
bsd
3,997
from __future__ import absolute_import, division, print_function, unicode_literals from .throughput_benchmark import ThroughputBenchmark # noqa: F401
rt65/pytorch
torch/utils/__init__.py
Python
bsd
152
from __future__ import absolute_import, division, print_function, unicode_literals import collections Entry = collections.namedtuple('Entry', 'version, hash') def update_hash(seed, value): # Good old boost::hash_combine # https://www.boost.org/doc/libs/1_35_0/doc/html/boost/hash_combine_id241013.html re...
rt65/pytorch
torch/utils/_cpp_extension_versioner.py
Python
bsd
1,854
from torch._C import _set_backcompat_broadcast_warn from torch._C import _get_backcompat_broadcast_warn from torch._C import _set_backcompat_keepdim_warn from torch._C import _get_backcompat_keepdim_warn class Warning(object): def __init__(self, setter, getter): self.setter = setter self.getter = ...
rt65/pytorch
torch/utils/backcompat/__init__.py
Python
bsd
675
import argparse import cProfile import pstats import sys import os import torch from torch.autograd import profiler from torch.utils.collect_env import get_env_info def redirect_argv(new_argv): sys.argv[:] = new_argv[:] def compiled_with_cuda(sysinfo): if sysinfo.cuda_compiled_version: return 'comp...
rt65/pytorch
torch/utils/bottleneck/__main__.py
Python
bsd
7,222
from __future__ import absolute_import, division, print_function, unicode_literals import torch import warnings def detach_variable(inputs): if isinstance(inputs, tuple): out = [] for inp in inputs: if not isinstance(inp, torch.Tensor): out.append(inp) c...
rt65/pytorch
torch/utils/checkpoint.py
Python
bsd
10,382
# This script outputs relevant system environment info # Run it with `python collect_env.py`. from __future__ import absolute_import, division, print_function, unicode_literals import locale import re import subprocess import sys import os from collections import namedtuple try: import torch TORCH_AVAILABLE = ...
rt65/pytorch
torch/utils/collect_env.py
Python
bsd
12,461
from __future__ import absolute_import, division, print_function, unicode_literals import copy import glob import imp import os import re import setuptools import subprocess import sys import sysconfig import tempfile import warnings import collections import torch from .file_baton import FileBaton from ._cpp_extensio...
rt65/pytorch
torch/utils/cpp_extension.py
Python
bsd
48,494
from .sampler import Sampler, SequentialSampler, RandomSampler, SubsetRandomSampler, WeightedRandomSampler, BatchSampler # noqa: F401 from .distributed import DistributedSampler # noqa: F401 from .dataset import Dataset, IterableDataset, TensorDataset, ConcatDataset, ChainDataset, Subset, random_split # noqa: F401 f...
rt65/pytorch
torch/utils/data/__init__.py
Python
bsd
399
from .sampler import Sampler as Sampler, SequentialSampler as SequentialSampler, RandomSampler as RandomSampler, \ SubsetRandomSampler as SubsetRandomSampler, WeightedRandomSampler as WeightedRandomSampler, BatchSampler as BatchSampler from .distributed import DistributedSampler as DistributedSampler from .dataset ...
rt65/pytorch
torch/utils/data/__init__.pyi
Python
bsd
513
r"""Utility classes & functions for data loading. Code in this folder is mostly used by ../dataloder.py. A lot of multiprocessing is used in data loading, which only supports running functions defined in global environment (py2 can't serialize static methods). Therefore, for code tidiness we put these functions into d...
rt65/pytorch
torch/utils/data/_utils/__init__.py
Python
bsd
1,529
r""""Contains definitions of the methods used by the _DataLoaderIter workers to collate samples fetched from dataset into Tensor(s). These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import torch import re from torch._six import container_abcs, string_classes, int_classes...
rt65/pytorch
torch/utils/data/_utils/collate.py
Python
bsd
3,373
r""""Contains definitions of the methods used by the _DataLoaderIter to fetch data from an iterable-style or map-style dataset. This logic is shared in both single- and multi-processing data loading. """ class _BaseDatasetFetcher(object): def __init__(self, dataset, auto_collation, collate_fn, drop_last): ...
rt65/pytorch
torch/utils/data/_utils/fetch.py
Python
bsd
1,801
r""""Contains definitions of the methods used by the _DataLoaderIter to put fetched tensors into pinned memory. These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import torch from torch._six import queue, container_abcs, string_classes from . import MP_STATUS_CHECK_INTERV...
rt65/pytorch
torch/utils/data/_utils/pin_memory.py
Python
bsd
2,081
r""""Signal handling for multiprocessing data loading. NOTE [ Signal handling in multiprocessing data loading ] In cases like DataLoader, if a worker process dies due to bus error/segfault or just hang, the main process will hang waiting for data. This is difficult to avoid on PyTorch side as it can be caused by limi...
rt65/pytorch
torch/utils/data/_utils/signal_handling.py
Python
bsd
3,072
r""""Contains definitions of the methods used by the _DataLoaderIter workers. These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import torch import random import os from collections import namedtuple from torch._six import queue from torch._utils import ExceptionWrapper f...
rt65/pytorch
torch/utils/data/_utils/worker.py
Python
bsd
8,278
r"""Definition of the DataLoader and it's iterator _DataLoaderIter classes. To support these two classes, in `./_utils` we define many utility methods and functions to be run in multiprocessing. E.g., the data loading worker loop is in `./_utils/worker.py`. """ import torch import multiprocessing as python_multiproce...
rt65/pytorch
torch/utils/data/dataloader.py
Python
bsd
46,162
from typing import Any, Callable, TypeVar, Generic, overload, Sequence, List from . import Dataset, Sampler T_co = TypeVar('T_co', covariant=True) T = TypeVar('T') _worker_init_fn_t = Callable[[int], None] # Ideally we would parameterize `DataLoader` by the return type of `collate_fn`, but there is currently no way t...
rt65/pytorch
torch/utils/data/dataloader.pyi
Python
bsd
1,764
import bisect import warnings from torch._utils import _accumulate from torch import randperm class Dataset(object): r"""An abstract class representing a :class:`Dataset`. All datasets that represent a map from keys to data samples should subclass it. All subclasses should overrite :meth:`__getitem__`, ...
rt65/pytorch
torch/utils/data/dataset.py
Python
bsd
10,586
from typing import TypeVar, Generic, Iterable, Sequence, List, Tuple from ... import Tensor T_co = TypeVar('T_co', covariant=True) T = TypeVar('T') class Dataset(Generic[T_co]): def __getitem__(self, index: int) -> T_co: ... def __len__(self) -> int: ... def __add__(self, other: T_co) -> 'ConcatDataset[T_c...
rt65/pytorch
torch/utils/data/dataset.pyi
Python
bsd
886
import math import torch from . import Sampler import torch.distributed as dist class DistributedSampler(Sampler): """Sampler that restricts data loading to a subset of the dataset. It is especially useful in conjunction with :class:`torch.nn.parallel.DistributedDataParallel`. In such case, each proc...
rt65/pytorch
torch/utils/data/distributed.py
Python
bsd
2,381
from typing import TypeVar, Optional, Iterable from . import Sampler, Dataset T_co = TypeVar('T_co', covariant=True) class DistributedSampler(Sampler[T_co]): def __init__(self, dataset: Dataset, num_replicas: Optional[int]=..., rank: Optional[int]=...): ... def __iter__(self) -> Iterable[int]: ... def __le...
rt65/pytorch
torch/utils/data/distributed.pyi
Python
bsd
391
import torch from torch._six import int_classes as _int_classes class Sampler(object): r"""Base class for all Samplers. Every Sampler subclass has to provide an :meth:`__iter__` method, providing a way to iterate over indices of dataset elements, and a :meth:`__len__` method that returns the length o...
rt65/pytorch
torch/utils/data/sampler.py
Python
bsd
8,380
from typing import Iterator, Optional, Sequence, List, TypeVar, Generic, Sized T_co = TypeVar('T_co', covariant=True) class Sampler(Generic[T_co]): def __init__(self, data_source: Sized) -> None: ... def __iter__(self) -> Iterator[T_co]: ... def __len__(self) -> int: ... class SequentialSampler(Sampler[in...
rt65/pytorch
torch/utils/data/sampler.pyi
Python
bsd
886
from __future__ import absolute_import, division, print_function, unicode_literals import torch from torch._C import _from_dlpack as from_dlpack from torch._C import _to_dlpack as to_dlpack torch._C._add_docstr(from_dlpack, r"""from_dlpack(dlpack) -> Tensor Decodes a DLPack to a tensor. Args: dlpack: a PyCapsul...
rt65/pytorch
torch/utils/dlpack.py
Python
bsd
725
raise ImportError("torch.utils.ffi is deprecated. Please use cpp extensions instead.")
rt65/pytorch
torch/utils/ffi/__init__.py
Python
bsd
87
from __future__ import absolute_import, division, print_function, unicode_literals import os import sys import time if sys.version < '3.3': # Note(jiayq): in Python 2, FileExistsError is not defined and the # error manifests it as OSError. FileExistsError = OSError class FileBaton: '''A primitive, fi...
rt65/pytorch
torch/utils/file_baton.py
Python
bsd
1,615
from __future__ import absolute_import, division, print_function, unicode_literals import collections import weakref import warnings class RemovableHandle(object): """A handle which provides the capability to remove a hook.""" next_id = 0 def __init__(self, hooks_dict): self.hooks_dict_ref = wea...
rt65/pytorch
torch/utils/hooks.py
Python
bsd
1,926
from typing import Any class RemovableHandle: def __init__(self, hooks_dict: Any) -> None: ... def remove(self) -> None: ... def __enter__(self): ... def __exit__(self, type: Any, value: Any, tb: Any) -> None: ...
rt65/pytorch
torch/utils/hooks.pyi
Python
bsd
232
from __future__ import absolute_import, division, print_function, unicode_literals import torch class MkldnnLinear(torch.jit.ScriptModule): def __init__(self, dense_module): super(MkldnnLinear, self).__init__() self.register_buffer('weight', dense_module.weight.to_mkldnn()) if dense_modul...
rt65/pytorch
torch/utils/mkldnn.py
Python
bsd
5,094
# torchvision imports tqdm from here. from torch.hub import tqdm, load_state_dict_from_url as load_url # noqa: F401
rt65/pytorch
torch/utils/model_zoo.py
Python
bsd
117
try: from tensorboard.summary.writer.record_writer import RecordWriter # noqa F401 except ImportError: raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. ' 'This should be available in 1.14 or above.') from .writer import FileWriter, SummaryW...
rt65/pytorch
torch/utils/tensorboard/__init__.py
Python
bsd
339
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import copy import logging import os import re import six from tensorboard.compat.proto.graph_pb2 import GraphDef from tensorboard.compat.proto.node_def_pb2 import NodeD...
rt65/pytorch
torch/utils/tensorboard/_caffe2_graph.py
Python
bsd
26,572
""" This module converts objects into numpy array. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import torch import six def make_np(x): """ Args: x: An instance of torch tensor or caffe blob name Returns: ...
rt65/pytorch
torch/utils/tensorboard/_convert_np.py
Python
bsd
1,019
import os import math import numpy as np from ._convert_np import make_np from ._utils import make_grid from posixpath import join def make_tsv(metadata, save_path, metadata_header=None): if not metadata_header: metadata = [str(x) for x in metadata] else: assert len(metadata_header) == len(met...
rt65/pytorch
torch/utils/tensorboard/_embedding.py
Python
bsd
2,584
from tensorboard.compat.proto.graph_pb2 import GraphDef from tensorboard.compat.proto.node_def_pb2 import NodeDef from tensorboard.compat.proto.versions_pb2 import VersionDef from tensorboard.compat.proto.attr_value_pb2 import AttrValue from tensorboard.compat.proto.tensor_shape_pb2 import TensorShapeProto def load_o...
rt65/pytorch
torch/utils/tensorboard/_onnx_graph.py
Python
bsd
1,756
from tensorboard.compat.proto.node_def_pb2 import NodeDef from tensorboard.compat.proto.attr_value_pb2 import AttrValue from tensorboard.compat.proto.tensor_shape_pb2 import TensorShapeProto def attr_value_proto(dtype, shape, s): """Creates a dict of objects matching https://github.com/tensorflow/tensorboard/...
rt65/pytorch
torch/utils/tensorboard/_proto_graph.py
Python
bsd
1,688
from collections import OrderedDict from tensorboard.compat.proto.config_pb2 import RunMetadata from tensorboard.compat.proto.graph_pb2 import GraphDef from tensorboard.compat.proto.step_stats_pb2 import StepStats, DeviceStepStats from tensorboard.compat.proto.versions_pb2 import VersionDef import torch from ._proto_...
rt65/pytorch
torch/utils/tensorboard/_pytorch_graph.py
Python
bsd
10,415
import numpy as np # Functions for converting def figure_to_image(figures, close=True): """Render matplotlib figure to numpy format. Note that this requires the ``matplotlib`` package. Args: figure (matplotlib.pyplot.figure) or list of figures: figure or a list of figures close (bool): F...
rt65/pytorch
torch/utils/tensorboard/_utils.py
Python
bsd
4,068
from __future__ import absolute_import from __future__ import division from __future__ import print_function import json import logging import numpy as np import os import re as _re # pylint: disable=unused-import from six.moves import range from tensorboard.compat.proto.summary_pb2 import Summary from tensorboard.c...
rt65/pytorch
torch/utils/tensorboard/summary.py
Python
bsd
27,420
"""Provides an API for writing protocol buffers to event files to be consumed by TensorBoard for visualization.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import six import time import torch from tensorboard.compat.proto.event_pb2 import ...
rt65/pytorch
torch/utils/tensorboard/writer.py
Python
bsd
42,971
from __future__ import absolute_import, division, print_function, unicode_literals import torch._C def format_time(time_us=None, time_ms=None, time_s=None): '''Defines how to format time''' assert sum([time_us is not None, time_ms is not None, time_s is not None]) == 1 US_IN_SECOND = 1e6 US_IN_MS = 1...
rt65/pytorch
torch/utils/throughput_benchmark.py
Python
bsd
5,999
Free AI Image Generator No sign-up. Instant results. Open Now