id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
21,200 | import logging
import math
import os
from abc import ABC, abstractmethod
from functools import wraps
from typing import Any, Dict, List, Optional, Union
import torch
import torch.distributed as dist
from torch import Tensor
from torch.nn import Module, Parameter
from torch.nn.parallel.parallel_apply import parallel_app... | Cache previous return of GPUtil to be re-used in case future GPUtil call fails to detect available devices. |
21,201 | import logging
import math
from typing import Any, Dict, List, Optional, Union
import numpy as np
import torch
from torch import Tensor
from torch.nn import Module, Parameter
from torch.optim.optimizer import Optimizer
from sparseml.pytorch.sparsification.modifier import ModifierProp, PyTorchModifierYAML
from sparseml.... | Cosine interpolation from init_value to end_value given by the law: f(t) = end_value + (1/2) * (init_value - end_value) (1 + cos(pi t / t_max)) :param t: current timestep :param t_max: maximal timestep :param init_value: initial value :param end_value: final value at t_max |
21,202 | import logging
import math
from typing import Any, Dict, List, Optional, Union
import numpy as np
import torch
from torch import Tensor
from torch.nn import Module, Parameter
from torch.optim.optimizer import Optimizer
from sparseml.pytorch.sparsification.modifier import ModifierProp, PyTorchModifierYAML
from sparseml.... | A function returning the tensor with all but topk fraction elements set to 0. :param tensor: the input tensor :param fraction: fraction of nonzero elements |
21,203 | import logging
from copy import deepcopy
from typing import Dict, List, Optional, Union
import torch
from torch.nn import Module
from torch.utils.hooks import RemovableHandle
from sparseml.optim import ModifierProp
from sparseml.pytorch.sparsification.distillation.modifier_distillation_base import (
BaseDistillatio... | null |
21,204 | import logging
from copy import deepcopy
from typing import Dict, List, Optional, Union
import torch
from torch.nn import Module
from torch.utils.hooks import RemovableHandle
from sparseml.optim import ModifierProp
from sparseml.pytorch.sparsification.distillation.modifier_distillation_base import (
BaseDistillatio... | null |
21,205 | import logging
from copy import deepcopy
from typing import Dict, List, Optional, Union
import torch
from torch.nn import Module
from torch.utils.hooks import RemovableHandle
from sparseml.optim import ModifierProp
from sparseml.pytorch.sparsification.distillation.modifier_distillation_base import (
BaseDistillatio... | null |
21,206 | import logging
from copy import deepcopy
from typing import Dict, List, Optional, Union
import torch
from torch.nn import Module
from torch.utils.hooks import RemovableHandle
from sparseml.optim import ModifierProp
from sparseml.pytorch.sparsification.distillation.modifier_distillation_base import (
BaseDistillatio... | :return: Optional index where the param group is if it is found. |
21,207 | import logging
from copy import deepcopy
from typing import Any, Dict, Iterable, List, Mapping, Optional, Union
import torch
import torch.nn.functional as TF
from torch import Tensor
from torch.nn import Module
from torch.optim import Optimizer
from sparseml.optim import BaseModifier, ModifierProp
from sparseml.pytorch... | null |
21,208 | from typing import List, Union
from torch.nn import Module
from torch.optim import Optimizer
from sparseml.optim import BaseModifier, ModifierProp
from sparseml.pytorch.sparsification.modifier import (
PyTorchModifierYAML,
ScheduledModifier,
)
from sparseml.pytorch.utils import BaseLogger
from sparseml.sparsifi... | null |
21,209 | import logging
from typing import Dict, List, Optional
import torch
from torch import Tensor
from torch.nn import Module, Parameter
from torch.optim import Optimizer
from sparseml.optim import BaseModifier, ModifierProp
from sparseml.pytorch.sparsification.modifier import (
PyTorchModifierYAML,
ScheduledModifie... | Removes in-place the given module parameters along either input or output channel dimensions for any of those channels that are completely pruned. Compresses parameters grouped according to the keys in the param_group_dependency_map and will update the opposite channels in the dependency map to remove those same channe... |
21,210 | import logging
from sparseml.sparsification import SparsificationInfo
_LOGGER = logging.getLogger(__name__)
The provided code snippet includes necessary dependencies for implementing the `sparsification_info` function. Write a Python function `def sparsification_info() -> SparsificationInfo` to solve the following pro... | Load the available setup for sparsifying model within pytorch. :return: The sparsification info for the pytorch framework :rtype: SparsificationInfo |
21,211 | import logging
import math
import warnings
from itertools import cycle
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type
import torch
from torch.nn import Module
from torch.optim.optimizer import Optimizer
from sparseml.optim import BaseModifier, ModifierProp
from sparseml.pytorch.sparsifica... | null |
21,212 | import logging
import math
import warnings
from itertools import cycle
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type
import torch
from torch.nn import Module
from torch.optim.optimizer import Optimizer
from sparseml.optim import BaseModifier, ModifierProp
from sparseml.pytorch.sparsifica... | null |
21,213 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | Wrap any BatchNormalization modules that are not fused with convolutions with BNWrapper to enable freezing/unfreezing of BN statistics :param module: module to potentially wrap the submodules of |
21,214 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | if any submodule of the given module has the attribute wrap_qat == True, then it will be replaced by a QATWrapper of it created by QATWrapper.from_module. Other named kwargs to the QATWrapper constructor must be contained in a dictionary under an attributed named `qat_wrapper_kwargs` :param module: module to potentiall... |
21,215 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | Wraps all Conv and Linear submodule with a qconfig with a QuantWrapper :param module: the module to modify :param name: name of the module to modify; default to None :param parent_module: parent module containing the module to modify; default to None :param layer_class_names: list of module class names to be added to t... |
21,216 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | Disables fake quantization of activations for all submodules of the given module with class name layer_class_names :param module: module to remove activation fake quantization for certain layers :param layer_class_names: list of layer class names that should be affected. e.x. ["Linear"] |
21,217 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | null |
21,218 | from copy import deepcopy
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
import torch
import torch.nn.intrinsic as nni
from packaging import version
from torch import quantization as torch_quantization
from torch.nn import BatchNorm2d, Conv2d, Embedding, Mo... | Performs fusion of Conv2d, BatchNorm2d, and ReLU layers found in the given module. To be fused, these layers must appear sequentially in module.named_modules() and be in the same submodule. Fuses either Conv2d -> BatchNorm2d, Conv2d -> ReLU, or Conv2d -> BatchNorm2d -> ReLU blocks If this function does not fuse the mod... |
21,219 | import logging
from collections import defaultdict
from copy import deepcopy
from typing import Any, Dict, List, NamedTuple, Optional, Union
import numpy
import onnx
import torch
from onnx import ModelProto, NodeProto, numpy_helper
from sparseml.onnx.utils import (
ONNXGraph,
get_batch_norm_params,
get_init... | A pass for removing unused Quantize->Dequantize blocks. This should be called at the end of conversion, once all of the conversions to quantized operators has been tried. Example: op -> QuantizeLinear -> DequantizeLinear -> non-quantized op => op -> non-quantized operator |
21,220 | import logging
from collections import defaultdict
from copy import deepcopy
from typing import Any, Dict, List, NamedTuple, Optional, Union
import numpy
import onnx
import torch
from onnx import ModelProto, NodeProto, numpy_helper
from sparseml.onnx.utils import (
ONNXGraph,
get_batch_norm_params,
get_init... | :param model: The model to convert, or a file path to it :param output_file_path: File path to save the converted model to :param inplace: If true, does conversion of model in place. Default is true :param use_qlinearconv: Set True to use legacy QLinearConv format instead of ConvInteger. QLinearConv requires output act... |
21,221 | import logging
from collections import defaultdict
from copy import deepcopy
from typing import Any, Dict, List, NamedTuple, Optional, Union
import numpy
import onnx
import torch
from onnx import ModelProto, NodeProto, numpy_helper
from sparseml.onnx.utils import (
ONNXGraph,
get_batch_norm_params,
get_init... | If the given model has a single FP32 input that feeds into a QuantizeLinear node, then the input will be changed to uint8 and the QuantizeLinear node will be deleted. This enables quantize graphs to take quantized inputs instead of floats. If no optimization is made, a RuntimeError will be raised. :param model: The mod... |
21,222 | from typing import Dict, List, Optional
import torch
from packaging import version
from torch.nn import Identity, Module
from sparseml.pytorch.sparsification.quantization.constants import (
FUSED_MODULE_NAMES,
NON_QUANTIZABLE_MODULE_NAMES,
)
from sparseml.pytorch.sparsification.quantization.helpers import (
... | Sets an appropriate `quantization_scheme` to targeted quantizable submodules :param model: module to attach QuantizationSchemes to :param scheme: default scheme to add to a target module unless overwritten by another scheme :param scheme_overrides: dictionary of module type names or submodule names mapped to a quantiza... |
21,223 | from typing import Dict, List, Optional
import torch
from packaging import version
from torch.nn import Identity, Module
from sparseml.pytorch.sparsification.quantization.constants import (
FUSED_MODULE_NAMES,
NON_QUANTIZABLE_MODULE_NAMES,
)
from sparseml.pytorch.sparsification.quantization.helpers import (
... | Converts submodules with set quantization_schemes into quantization aware modules with FakeQuantize modules in the model :param module: module to convert to QAT mode |
21,224 | from typing import Dict, List, Optional
import torch
from packaging import version
from torch.nn import Identity, Module
from sparseml.pytorch.sparsification.quantization.constants import (
FUSED_MODULE_NAMES,
NON_QUANTIZABLE_MODULE_NAMES,
)
from sparseml.pytorch.sparsification.quantization.helpers import (
... | :raises: RuntimeError if the installed torch version does not include support for quantization aware training |
21,225 | from copy import deepcopy
from functools import partial
from typing import Any, Dict, Optional, Union
import torch
from packaging import version
from pydantic import BaseModel, Field, validator
from torch.nn import Identity
class QuantizationArgs(BaseModel):
"""
Class representing user facing arguments to defin... | null |
21,226 | from copy import deepcopy
from functools import partial
from typing import Any, Dict, Optional, Union
import torch
from packaging import version
from pydantic import BaseModel, Field, validator
from torch.nn import Identity
def _parse_quantization_arg(arg: Any):
if arg == "None":
return None
return arg | null |
21,227 | import logging
import warnings
from itertools import cycle
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Tuple,
Union,
)
import torch
from torch.nn import Module
from torch.optim.optimizer import Optimizer
from sparseml.optim import BaseModifier, Mod... | null |
21,228 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,229 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,230 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,231 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,232 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,233 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,234 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,235 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | null |
21,236 | import datetime
import logging
import math
import os
import sys
import time
import warnings
from functools import update_wrapper
from types import SimpleNamespace
from typing import Callable, Optional
import torch
import torch.utils.data
import torchvision
from packaging import version
from torch import nn
from torch.u... | PyTorch classification training |
21,237 | import json
import logging
from pathlib import Path
from typing import Dict, Optional, Union
import torchvision
from torch.nn import Module
from torch.utils.data import DataLoader
from torchvision.transforms.functional import InterpolationMode
from tqdm import tqdm
import click
from sparseml.pytorch.models.registry imp... | null |
21,238 | import copy
import datetime
import errno
import hashlib
import logging
import os
import time
from collections import OrderedDict, defaultdict, deque
from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
def is_dist_avail_and_initialized():
if not dist.is_available():
return ... | null |
21,239 | import copy
import datetime
import errno
import hashlib
import logging
import os
import time
from collections import OrderedDict, defaultdict, deque
from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
def setup_for_distributed(is_master):
def init_distributed_mode(args):
if "RANK... | null |
21,240 | import copy
import datetime
import errno
import hashlib
import logging
import os
import time
from collections import OrderedDict, defaultdict, deque
from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `ave... | Loads checkpoints from inputs and returns a model with averaged weights. Original implementation taken from: https://github.com/pytorch/fairseq/blob/a48f235636557b8d3bc4922a6fa90f3a0fa57955/scripts/average_checkpoints.py#L16 Args: inputs (List[str]): An iterable of string paths of checkpoints to load from. Returns: A d... |
21,241 | import copy
import datetime
import errno
import hashlib
import logging
import os
import time
from collections import OrderedDict, defaultdict, deque
from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
The provided code snippet includes necessary dependencies for implementing the `sto... | This method can be used to prepare weights files for new models. It receives as input a model architecture and a checkpoint from the training script and produces a file with the weights ready for release. Examples: from torchvision import models as M # Classification model = M.mobilenet_v3_large(weights=None) print(sto... |
21,242 | import copy
import datetime
import errno
import hashlib
import logging
import os
import time
from collections import OrderedDict, defaultdict, deque
from typing import List, Optional, Tuple
import torch
import torch.distributed as dist
def set_weight_decay(
model: torch.nn.Module,
weight_decay: float,
norm... | null |
21,243 | import torch
from packaging import version
try:
import torch
_PARSED_TORCH_VERSION = version.parse(torch.__version__)
if _PARSED_TORCH_VERSION.major >= 2:
torch_compile_func = torch.compile
def raise_torch_compile_warning(*args, **kwargs):
warnings.warn("torch.compile is not... | null |
21,244 | import functools
import logging
import time
from abc import ABC, abstractmethod
from contextlib import contextmanager
from pathlib import Path
from typing import Dict, List, Union
import numpy as np
import torch
from sparseml.pytorch.utils import default_device
from sparseml.utils.datasets import IMAGENET_RGB_MEANS, IM... | Decorator to time a function |
21,245 | import os
import torch
from sparseml.pytorch.datasets.detection.helpers import (
AnnotatedImageTransforms,
bounding_box_and_labels_to_yolo_fmt,
random_horizontal_flip_image_and_annotations,
ssd_random_crop_image_and_annotations,
)
from sparseml.pytorch.datasets.registry import DatasetRegistry
from spars... | null |
21,246 | import os
import torch
import urllib.request as request
import zipfile
from sparseml.pytorch.datasets.detection.helpers import (
AnnotatedImageTransforms,
bounding_box_and_labels_to_yolo_fmt,
random_horizontal_flip_image_and_annotations,
ssd_random_crop_image_and_annotations,
)
from sparseml.pytorch.dat... | Wrapper for COCO detection dataset with Dataset Registry values properly created for a Yolo model trained on 80 classes. :param root: The root folder to find the dataset at, if not found will download here if download=True :param train: True if this is for the training distribution, False for the validation :param rand... |
21,247 | import os
import torch
import urllib.request as request
import zipfile
from sparseml.pytorch.datasets.detection.helpers import (
AnnotatedImageTransforms,
bounding_box_and_labels_to_yolo_fmt,
random_horizontal_flip_image_and_annotations,
ssd_random_crop_image_and_annotations,
)
from sparseml.pytorch.dat... | null |
21,248 | import random
from typing import Any, Callable, List, Tuple
import torch
from PIL import Image
from torch import Tensor
from sparseml.pytorch.utils import ssd_random_crop
The provided code snippet includes necessary dependencies for implementing the `ssd_random_crop_image_and_annotations` function. Write a Python func... | Wraps sparseml.pytorch.utils.ssd_random_crop to work in the AnnotatedImageTransforms pipeline. :param image: the image to crop :param annotations: a tuple of bounding boxes and their labels for this image :return: A tuple of the cropped image and annotations |
21,249 | import random
from typing import Any, Callable, List, Tuple
import torch
from PIL import Image
from torch import Tensor
from sparseml.pytorch.utils import ssd_random_crop
The provided code snippet includes necessary dependencies for implementing the `random_horizontal_flip_image_and_annotations` function. Write a Pyth... | Performs a horizontal flip on given image and bounding boxes with probability p. :param image: the image to randomly flip :param annotations: a tuple of bounding boxes and their labels for this image :param p: the probability to flip with. Default is 0.5 :return: A tuple of the randomly flipped image and annotations |
21,250 | import random
from typing import Any, Callable, List, Tuple
import torch
from PIL import Image
from torch import Tensor
from sparseml.pytorch.utils import ssd_random_crop
The provided code snippet includes necessary dependencies for implementing the `yolo_collate_fn` function. Write a Python function `def yolo_collate... | Collate function to be used for creating a DataLoader with values for Yolo model input. :param batch: a batch of data points and annotations transformed by bounding_box_and_labels_to_yolo_fmt :return: the batch stacked as tensors for all values except for the original annotations |
21,251 | import random
from typing import Any, Callable, List, Tuple
import torch
from PIL import Image
from torch import Tensor
from sparseml.pytorch.utils import ssd_random_crop
The provided code snippet includes necessary dependencies for implementing the `ssd_collate_fn` function. Write a Python function `def ssd_collate_f... | Collate function to be used for creating a DataLoader with values transformed by encode_annotation_bounding_boxes. :param batch: a batch of data points transformed by encode_annotation_bounding_boxes :return: the batch stacked as tensors for all values except for the original annotations |
21,252 | import random
from typing import Any, Callable, List, Tuple
import torch
from PIL import Image
from torch import Tensor
from sparseml.pytorch.utils import ssd_random_crop
def bounding_box_and_labels_to_yolo_fmt(annotations):
boxes, labels = annotations
if boxes.numel() == 0:
return torch.zeros(0, 5)
... | null |
21,253 | from typing import Any, Callable, List, Tuple, Union
import torch
from torch import Tensor
from torch.nn import Module
from torch.utils.data import DataLoader
from sparseml.optim import (
PruningLossSensitivityAnalysis,
default_pruning_sparsities_loss,
)
from sparseml.pytorch.optim.mask_creator_pruning import U... | Calculate the approximate sensitivity for an overall model. Range of the values are not scaled to anything, so must be taken in context with other known models. :param module: the model to calculate the sensitivity for :return: the approximated sensitivity |
21,254 | from typing import Any, Callable, List, Tuple, Union
import torch
from torch import Tensor
from torch.nn import Module
from torch.utils.data import DataLoader
from sparseml.optim import (
PruningLossSensitivityAnalysis,
default_pruning_sparsities_loss,
)
from sparseml.pytorch.optim.mask_creator_pruning import U... | Approximated kernel sparsity (pruning) loss analysis for a given model. Returns the results for each prunable param (conv, linear) in the model. :param module: the model to calculate the sparse sensitivity analysis for :param sparsity_levels: the sparsity levels to calculate the loss for for each param :return: the ana... |
21,255 | from typing import Any, Callable, List, Tuple, Union
import torch
from torch import Tensor
from torch.nn import Module
from torch.utils.data import DataLoader
from sparseml.optim import (
PruningLossSensitivityAnalysis,
default_pruning_sparsities_loss,
)
from sparseml.pytorch.optim.mask_creator_pruning import U... | Run a one shot sensitivity analysis for kernel sparsity. It does not retrain, and instead puts the model to eval mode. Moves layer by layer to calculate the sensitivity analysis for each and resets the previously run layers. Note, by default it caches the data. This means it is not parallel for data loading and the fir... |
21,256 | from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional
import torch
import torch.distributed as dist
from torch import Tensor
from torch.nn import Parameter
class PruningParamsScorer(ABC):
"""
Base abstract class for scoring model parameters for pruning
:param params: list of model... | :param params: List of Parameters for the created PruningParamsScorer to track :param score_type: String name of scoring type to use. Valid options are 'magnitude', or 'movement' |
21,257 | from typing import Any, Callable, List, Tuple, Union
from torch import Tensor
from torch.nn import Module
from torch.optim.optimizer import Optimizer
from torch.utils.data import DataLoader
from sparseml.optim import LRLossSensitivityAnalysis
from sparseml.pytorch.utils import (
DEFAULT_LOSS_KEY,
BaseLogger,
... | Implementation for handling running sensitivity analysis for learning rates on modules. :param module: the module to run the learning rate sensitivity analysis over, it is expected to already be on the correct device :param data: the data to run through the module for calculating the sensitivity analysis :param loss: t... |
21,258 | import random
from abc import ABC, abstractmethod
from typing import Iterable, List, Optional, Union
import torch
from torch import Tensor
class PruningMaskCreator(ABC):
"""
Base abstract class for a sparsity mask creator.
Subclasses should define all methods for creating masks
"""
def create_sparsi... | :param obj: Formatted string or block shape iterable specifying SparsityMaskCreator object to return :return: SparsityMaskCreator object created from obj |
21,259 | import logging
from typing import Any
from sparseml.base import Framework, get_version
from sparseml.framework import FrameworkInferenceProviderInfo, FrameworkInfo
from sparseml.pytorch.base import check_torch_install, torch
from sparseml.pytorch.sparsification import sparsification_info
from sparseml.sparsification im... | :param item: The item to detect the support for :type item: Any :return: True if the item is supported by pytorch, False otherwise :rtype: bool |
21,260 | import logging
from typing import Any
from sparseml.base import Framework, get_version
from sparseml.framework import FrameworkInferenceProviderInfo, FrameworkInfo
from sparseml.pytorch.base import check_torch_install, torch
from sparseml.pytorch.sparsification import sparsification_info
from sparseml.sparsification im... | Detect the information for the onnx/onnxruntime framework such as package versions, availability for core actions such as training and inference, sparsification support, and inference provider support. :return: The framework info for onnx/onnxruntime :rtype: FrameworkInfo |
21,261 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300Lite, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300MobileNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
fo... | SSD 300 Lite with MobileNet V2 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained MobileNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is ... |
21,262 | import math
from typing import List, Tuple, Union
from torch import Tensor, cat
from torch.nn import (
BatchNorm2d,
Conv2d,
MaxPool2d,
Module,
ModuleList,
Parameter,
Upsample,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
de... | null |
21,263 | import math
from typing import List, Tuple, Union
from torch import Tensor, cat
from torch.nn import (
BatchNorm2d,
Conv2d,
MaxPool2d,
Module,
ModuleList,
Parameter,
Upsample,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
de... | null |
21,264 | import math
from typing import List, Tuple, Union
from torch import Tensor, cat
from torch.nn import (
BatchNorm2d,
Conv2d,
MaxPool2d,
Module,
ModuleList,
Parameter,
Upsample,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
cla... | Yolo-V3 model with standard DarkNet-53 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained DarkNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Defau... |
21,265 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300ResNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
for an SS... | SSD 300 with ResNet 18 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained ResNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is True :param... |
21,266 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300ResNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
for an SS... | SSD 300 with ResNet 34 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained ResNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is True :param... |
21,267 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300ResNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
for an SS... | SSD 300 with ResNet 50 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained ResNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is True :param... |
21,268 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300ResNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
for an SS... | SSD 300 with ResNet 101 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained ResNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is True :para... |
21,269 | from typing import List, Union
from torch import nn
from sparseml.pytorch.models.detection import SSD300, SSDBackbone
from sparseml.pytorch.models.registry import ModelRegistry
class SSD300ResNetBackbone(SSDBackbone):
"""
Class to provide the feature extractor and define the additional conv layers
for an SS... | SSD 300 with ResNet 152 backbone; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes of objects to classify :param pretrained_backbone: True to load pretrained ResNet weights; to load a specific version give a string with the name of the version (optim, optim-perf). Default is True :para... |
21,270 | from inspect import getmembers, isfunction, signature
from typing import List, Union
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.utils import load_model
def _registry_constructor_wrapper(key, constructor_function):
# wraps the torchvision model constructor function to be compati... | null |
21,271 | from typing import Tuple, Union
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
MaxPool2d,
Module,
ModuleList,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry ... | null |
21,272 | from typing import Tuple, Union
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
MaxPool2d,
Module,
ModuleList,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry ... | null |
21,273 | from typing import Tuple, Union
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
MaxPool2d,
Module,
ModuleList,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry ... | Standard InceptionV3 implementation; expected input shape is (B, 3, 299, 299) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param enable_aux: True to enable the aux input for training, calculates aux logits from an earlie... |
21,274 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import ReLU
def _init... | null |
21,275 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import ReLU
def _init... | null |
21,276 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import ReLU
def _init... | null |
21,277 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import ReLU
class Mobi... | Standard MobileNet implementation with width=1.0; expected input shape is (B, 3, 224, 224) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :return: The created MobileNet Module |
21,278 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import ReLU
class Mobi... | Standard MobileNet implementation with width=1.0; expected input shape is (B, 3, 224, 224) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :return: The created MobileNet Module |
21,279 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
def _init... | null |
21,280 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
def _init... | null |
21,281 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
def _init... | null |
21,282 | from typing import List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegistry
from sparseml.pytorch.nn import Hardswish
class Dark... | DarkNet-53 implementation as described in the Yolo v3 paper; expected input shape is (B, 3, 256, 256) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :return: The created DarkNet Module |
21,283 | from collections import OrderedDict
from typing import Dict, List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegist... | null |
21,284 | from collections import OrderedDict
from typing import Dict, List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegist... | null |
21,285 | from collections import OrderedDict
from typing import Dict, List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegist... | null |
21,286 | from collections import OrderedDict
from typing import Dict, List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegist... | null |
21,287 | from collections import OrderedDict
from typing import Dict, List, Union
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
Softmax,
init,
)
from sparseml.pytorch.models.registry import ModelRegist... | Standard MobileNet V2 implementation for a width multiplier; expected input shape is (B, 3, 224, 224) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :return: The created MobileNet Module |
21,288 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | null |
21,289 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B0 implementation; expected input shape is (B, 3, 224, 224) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,290 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B1 implementation; expected input shape is (B, 3, 240, 240) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,291 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B2 implementation; expected input shape is (B, 3, 260, 260) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,292 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B3 implementation; expected input shape is (B, 3, 300, 300) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,293 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B4 implementation; expected input shape is (B, 3, 380, 380) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,294 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B5 implementation; expected input shape is (B, 3, 456, 456) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,295 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B6 implementation; expected input shape is (B, 3, 528, 528) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,296 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNet B0 implementation; expected input shape is (B, 3, 600, 600) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :param se_mod: If true, moves squeeze-excit... |
21,297 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNetV2-s implementation; expected input shape is (B, 3, 384, 384) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :return: The created EfficientNet_V2-S Mod... |
21,298 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNetV2-m implementation; expected input shape is (B, 3, 480, 480) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :return: The created EfficientNet_V2-M Mod... |
21,299 | import math
from collections import OrderedDict
from typing import Any, List, Mapping, Optional, Tuple
import torch
from torch import Tensor
from torch.nn import (
AdaptiveAvgPool2d,
BatchNorm2d,
Conv2d,
Dropout,
Linear,
Module,
Sequential,
Sigmoid,
SiLU,
Softmax,
)
from sparseml... | EfficientNetV2-l implementation; expected input shape is (B, 3, 480, 480) :param num_classes: the number of classes to classify :param class_type: one of [single, multi] to support multi class training; default single :param dropout: the amount of dropout to use while training :return: The created EfficientNet_V2-L Mod... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.