id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
7,678
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def piecewise_exp_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return alpha / 2 * (- alpha * x.abs()).exp_() * grad_output, None
null
7,679
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def sigmoid_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): sgax = (x * alpha).sigmoid_() return grad_output * (1. - sgax) * sgax * alpha, None
null
7,680
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def soft_sign_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return grad_output / (2 * alpha * (1 / alpha + x.abs()).pow_(2)), None
null
7,681
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def atan_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return alpha / 2 / (1 + (math.pi / 2 * alpha * x).pow_(2)) * grad_output, None
null
7,682
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def nonzero_sign_log_abs_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return grad_output / (1 / alpha + x.abs()), None
null
7,683
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def erf_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return grad_output * (- (x * alpha).pow_(2)).exp_() * (alpha / math.sqrt(math.pi)), None
null
7,684
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def piecewise_leaky_relu_backward(grad_output: torch.Tensor, x: torch.Tensor, w: float, c: float): mask_width = (x.abs() < w) mask_c = mask_width.logical_not() return grad_output * x.masked_fill(...
null
7,685
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def leaky_k_relu_backward(grad_output: torch.Tensor, x: torch.Tensor, leak: float, k: float): mask1 = (x >= 0.).to(x) grad_x = mask1 * k + (1. - mask1) * leak return grad_output * grad_x, None, N...
null
7,686
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def fake_numerical_gradient_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): grad_x = torch.clamp_max(((x >= 0.) * 2. - 1.) / x, alpha) return grad_output * grad_x, None
null
7,687
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def log_tailed_relu_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): mask_gt1 = x > 1. mask_le0 = x <= 0. grad_x = torch.ones_like(grad_output) grad_x[mask_gt1] = 1. / x[ma...
null
7,688
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def deterministic_pass_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return grad_output, None
null
7,689
import torch import torch.nn as nn import torch.nn.functional as F import math from .auto_cuda import cfunction def rect_backward(grad_output: torch.Tensor, x: torch.Tensor, alpha: float): return alpha * (x.abs() < 0.5 / alpha).to(x) * grad_output, None
null
7,690
import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.fusion import * from torch.autograd import Function from torch import Tensor from collections import namedtuple from ...activation_based import layer from ..neuron import LIFNode from torch.nn.functional import interpolate from ..surrogate import...
:param net_arch: network level sample rate 0: down 1: None 2: Up :type net_arch: numpy.ndarray :return: network level architecture network_space[layer][level][sample]: layer: 0 - 8 level: sample_level {0: 1, 1: 2, 2: 4, 3: 8} sample: 0: down 1: None 2: Up :rtype: numpy.ndarray Convert network level sample rate like [0,...
7,691
import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.fusion import * from torch.autograd import Function from torch import Tensor from collections import namedtuple from ...activation_based import layer from ..neuron import LIFNode from torch.nn.functional import interpolate from ..surrogate import...
null
7,692
import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.fusion import * from torch.autograd import Function from torch import Tensor from collections import namedtuple from ...activation_based import layer from ..neuron import LIFNode from torch.nn.functional import interpolate from ..surrogate import...
null
7,693
import torch.nn as nn import torch.nn.functional as F from torch.nn.utils.fusion import * from torch.autograd import Function from torch import Tensor from collections import namedtuple from ...activation_based import layer from ..neuron import LIFNode from torch.nn.functional import interpolate from ..surrogate import...
null
7,694
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def sequential_forward(sequential, x_seq): assert isinstance(sequential, nn.Sequential) out = x_seq for i in range(len(sequential)): m = sequential[i] if isinstance(m, neuron.BaseNode): ...
null
7,695
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,696
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param norm_layer: a batch norm layer :type norm_layer: callable :param spiking_neuron: a spiking neuron l...
7,697
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,698
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param norm_layer: a batch norm layer :type norm_layer: callable :param spiking_neuron: a spiking neuron l...
7,699
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,700
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param norm_layer: a batch norm layer :type norm_layer: callable :param spiking_neuron: a spiking neuron l...
7,701
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,702
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, batch_norm, pretrained, progress, norm_layer: callable = None, spiking_neuron: callable = None, **kwargs): if pretrained: kwargs['init_weights'] = False if batch_norm: ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param norm_layer: a batch norm layer :type norm_layer: callable :param spiking_neuron: a spiking neuron l...
7,703
import torch import torch.nn as nn from copy import deepcopy from .. import layer def sew_function(x: torch.Tensor, y: torch.Tensor, cnf:str): if cnf == 'ADD': return x + y elif cnf == 'AND': return x * y elif cnf == 'IAND': return x * (1. - y) else: raise NotImplemented...
null
7,704
import torch import torch.nn as nn from copy import deepcopy from .. import layer The provided code snippet includes necessary dependencies for implementing the `conv3x3` function. Write a Python function `def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1)` to solve the following problem: 3x3 convoluti...
3x3 convolution with padding
7,705
import torch import torch.nn as nn from copy import deepcopy from .. import layer The provided code snippet includes necessary dependencies for implementing the `conv1x1` function. Write a Python function `def conv1x1(in_planes, out_planes, stride=1)` to solve the following problem: 1x1 convolution Here is the functi...
1x1 convolution
7,706
import torch import torch.nn as nn from copy import deepcopy from .. import layer class BasicBlock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None, cnf: str = None, spiking_neuron: callable = None, **...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a spiking neuron...
7,707
import torch import torch.nn as nn from copy import deepcopy from .. import layer class BasicBlock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None, cnf: str = None, spiking_neuron: callable = None, **...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a spiking neuron...
7,708
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a spiking neuron...
7,709
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a spiking neuron...
7,710
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a single step ne...
7,711
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a single step ne...
7,712
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a single step ne...
7,713
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a single step ne...
7,714
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param cnf: the name of spike-element-wise function :type cnf: str :param spiking_neuron: a single step ne...
7,715
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG (sWS), model used in 'Online Training Through Time for Spiking Neural Networks <https://openreview.net/forum?id=Siv3nHYHheI>' :rtype: torch.nn.Module
7,716
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-11 :rtype: torch.nn.Module
7,717
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-11 with weight standardization :rtype: torch.nn.Module
7,718
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-13 :rtype: torch.nn.Module
7,719
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-11 with weight standardization :rtype: torch.nn.Module
7,720
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-16 :rtype: torch.nn.Module
7,721
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-16 with weight standardization :rtype: torch.nn.Module
7,722
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-19 :rtype: torch.nn.Module
7,723
import torch import torch.nn as nn from copy import deepcopy from .. import functional, neuron, layer def _spiking_vgg(arch, cfg, weight_standardization, spiking_neuron: callable = None, **kwargs): model = OTTTSpikingVGG(cfg=cfgs[cfg], weight_standardization=weight_standardization, spiking_neuron=spiking_neuron, **...
:param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `spiking_neuron` :type kwargs: dict :return: Spiking VGG-19 with weight standardization :rtype: torch.nn.Module
7,726
import torch import torch.nn as nn from copy import deepcopy from .. import layer class BasicBlock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None, spiking_neuron: callable = None, **kwargs): ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,727
import torch import torch.nn as nn from copy import deepcopy from .. import layer class BasicBlock(nn.Module): expansion = 1 def __init__(self, inplanes, planes, stride=1, downsample=None, groups=1, base_width=64, dilation=1, norm_layer=None, spiking_neuron: callable = None, **kwargs): ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,728
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,729
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a spiking neuron layer :type spiking_neuron: callable :param kwargs: kwargs for `sp...
7,730
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a single step neuron :type spiking_neuron: callable :param kwargs: kwargs for `spik...
7,731
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a single step neuron :type spiking_neuron: callable :param kwargs: kwargs for `spik...
7,732
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a single step neuron :type spiking_neuron: callable :param kwargs: kwargs for `spik...
7,733
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a single step neuron :type spiking_neuron: callable :param kwargs: kwargs for `spik...
7,734
import torch import torch.nn as nn from copy import deepcopy from .. import layer class Bottleneck(nn.Module): # Bottleneck in torchvision places the stride for downsampling at 3x3 convolution(self.conv2) # while original implementation places the stride at the first 1x1 convolution(self.conv1) # according ...
:param pretrained: If True, the SNN will load parameters from the ANN pre-trained on ImageNet :type pretrained: bool :param progress: If True, displays a progress bar of the download to stderr :type progress: bool :param spiking_neuron: a single step neuron :type spiking_neuron: callable :param kwargs: kwargs for `spik...
7,735
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist The provided code snippet includes necessary dependencies for implementing the `accuracy` function. Write a Python function `def accuracy(o...
Computes the accuracy over the k top predictions for the specified values of k
7,736
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist def mkdir(path): try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: raise
null
7,737
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist def is_dist_avail_and_initialized(): if not dist.is_available(): return False if not dist.is_initialized(): return F...
null
7,738
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist def is_main_process(): return get_rank() == 0 def save_on_master(*args, **kwargs): if is_main_process(): torch.save(*args, ...
null
7,739
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist def setup_for_distributed(is_master): """ This function disables printing when not in master process """ import builtins as ...
null
7,740
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist The provided code snippet includes necessary dependencies for implementing the `average_checkpoints` function. Write a Python function `def...
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...
7,741
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist The provided code snippet includes necessary dependencies for implementing the `store_model_weights` function. Write a Python function `def...
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(pretrained=False) print...
7,742
import copy import datetime import errno import hashlib import os import time from collections import defaultdict, deque, OrderedDict import torch import torch.distributed as dist def is_dist_avail_and_initialized(): if not dist.is_available(): return False if not dist.is_initialized(): return F...
null
7,743
import datetime import os import time import warnings from .tv_ref_classify import presets, transforms, utils import torch import torch.utils.data import torchvision from .tv_ref_classify.sampler import RASampler from torch import nn from torch.utils.data.dataloader import default_collate from torchvision.transforms.fu...
null
7,744
import datetime import os import time import warnings from .tv_ref_classify import presets, transforms, utils import torch import torch.utils.data import torchvision from .tv_ref_classify.sampler import RASampler from torch import nn from torch.utils.data.dataloader import default_collate from torchvision.transforms.fu...
null
7,745
import torch import torch.nn as nn from copy import deepcopy from .. import layer class MNISTNet(nn.Module): def __init__(self, channels=128, spiking_neuron: callable = None, **kwargs): super().__init__() self.conv_fc = nn.Sequential( layer.Conv2d(1, channels, kernel_size=3, padding=1, b...
null
7,746
from typing import Callable, Dict, Optional, Tuple import numpy as np from .. import datasets as sjds import os import rarfile import time def load_events(fname: str): events = np.load(fname) e_pos = events['pos'] e_neg = events['neg'] e_pos = np.hstack((e_pos, np.ones((e_pos.shape[0], 1)))) e_neg ...
null
7,747
from dataclasses import dataclass import numpy as np import math from typing import Callable, Optional, Tuple, Union,Any, List def slice_events_by_time_bins(events: np.ndarray, bin_count: int, overlap: float = 0.0): return SliceByTimeBins(bin_count=bin_count, overlap=overlap).slice(events, None)[0] def slice_events...
Accumulate events to frames by slicing along constant time (time_window), constant number of events (event_count) or constant number of frames (n_time_bins / n_event_bins). Parameters: events: ndarray of shape [num_events, num_event_channels] sensor_size: size of the sensor that was used [W,H,P] time_window (None): win...
7,748
from dataclasses import dataclass import numpy as np import math from typing import Callable, Optional, Tuple, Union,Any, List def bina_rep(frames: np.ndarray) -> np.ndarray: """Computes one Bina-Rep frame from the sequence of N binary event-frames in parameter. Args: frames (numpy.ndarray): the sequenc...
Representation that takes T*B binary event frames to produce a sequence of T frames of N-bit numbers. To do so, N binary frames are interpreted as a single frame of N-bit representation. Taken from the paper Barchid et al. 2022, Bina-Rep Event Frames: a Simple and Effective Representation for Event-based cameras https:...
7,749
from dataclasses import dataclass import numpy as np import math from typing import Callable, Optional, Tuple, Union,Any, List The provided code snippet includes necessary dependencies for implementing the `to_voxel_grid_numpy` function. Write a Python function `def to_voxel_grid_numpy(events, sensor_size, n_time_bins...
Build a voxel grid with bilinear interpolation in the time domain from a set of events. Implements the event volume from Zhu et al. 2019, Unsupervised event-based learning of optical flow, depth, and egomotion Parameters: events: ndarray of shape [num_events, num_event_channels] sensor_size: size of the sensor that was...
7,750
from typing import Callable, Dict, Optional, Tuple import h5py import numpy as np from torch.utils.data import Dataset from torchvision.datasets import utils from torchvision.datasets.utils import extract_archive import os import multiprocessing from concurrent.futures import ThreadPoolExecutor import time from .. impo...
null
7,751
from typing import Callable, Dict, Optional, Tuple import h5py import numpy as np from torch.utils.data import Dataset from torchvision.datasets import utils from torchvision.datasets.utils import extract_archive import os import multiprocessing from concurrent.futures import ThreadPoolExecutor import time from .. impo...
null
7,752
from typing import Callable, Dict, Optional, Tuple import h5py import numpy as np from torch.utils.data import Dataset from torchvision.datasets import utils from torchvision.datasets.utils import extract_archive import os import multiprocessing from concurrent.futures import ThreadPoolExecutor import time from .. impo...
null
7,753
from struct import unpack, pack import numpy as np import sys def peek(f, length=1): pos = f.tell() data = f.read(length) f.seek(pos) return data from typing import Callable, Dict, Optional, Tuple from .. import datasets as sjds from torchvision.datasets.utils import extract_archive import os import mul...
reads ATIS td events in .dat format input: filename: string, path to the .dat file orig_at_zero: bool, if True, timestamps will start at 0 drop_negative_dt: bool, if True, events with a timestamp greater than the previous event are dismissed verbose: bool, if True, verbose mode. events_restriction: list [min ts, max ts...
7,754
import os from typing import Callable, Tuple, Dict, Optional from pathlib import Path import torch import torchaudio from torch.utils.data import Dataset from torch import Tensor from torchvision.datasets.utils import ( download_url, extract_archive ) from torchvision.datasets.utils import verify_str_arg import...
null
7,755
from typing import Callable, Dict, Optional, Tuple import numpy as np from .. import datasets as sjds from torchvision.datasets.utils import extract_archive import os import multiprocessing from concurrent.futures import ThreadPoolExecutor import time from .. import configure from ..datasets import np_savez def load_ra...
null
7,756
import os import io import json import numpy as np import cv2 import gradio as gr import modules.scripts as scripts from modules import script_callbacks from modules.shared import opts from modules.paths import models_path from basicsr.utils.download_util import load_file_from_url from scripts.openpose.body import Body...
null
7,757
import math import numpy as np import matplotlib import cv2 def padRightDownCorner(img, stride, padValue): h = img.shape[0] w = img.shape[1] pad = 4 * [None] pad[0] = 0 # up pad[1] = 0 # left pad[2] = 0 if (h % stride == 0) else stride - (h % stride) # down pad[3] = 0 if (w % stride == 0) ...
null
7,758
import math import numpy as np import matplotlib import cv2 def transfer(model, model_weights): transferred_model_weights = {} for weights_name in model.state_dict().keys(): transferred_model_weights[weights_name] = model_weights['.'.join(weights_name.split('.')[1:])] return transferred_model_weigh...
null
7,759
import math import numpy as np import matplotlib import cv2 def draw_bodypose(canvas, candidate, subset): stickwidth = 4 limbSeq = [[2, 3], [2, 6], [3, 4], [4, 5], [6, 7], [7, 8], [2, 9], [9, 10], \ [10, 11], [2, 12], [12, 13], [13, 14], [2, 1], [1, 15], [15, 17], \ [1, 16], [16, ...
null
7,760
import math import numpy as np import matplotlib import cv2 def draw_handpose(canvas, all_hand_peaks, show_number=False): edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], \ [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], ...
null
7,761
import math import numpy as np import matplotlib import cv2 The provided code snippet includes necessary dependencies for implementing the `handDetect` function. Write a Python function `def handDetect(candidate, subset, oriImg)` to solve the following problem: return value: [[x, y, w, True if left hand else False]]. ...
return value: [[x, y, w, True if left hand else False]]. width=height since the network require squared input. x, y is the coordinate of top left
7,762
import math import numpy as np import matplotlib import cv2 def npmax(array): arrayindex = array.argmax(1) arrayvalue = array.max(1) i = arrayvalue.argmax() j = arrayindex[i] return i, j
null
7,763
import torch from collections import OrderedDict import torch import torch.nn as nn def make_layers(block, no_relu_layers): layers = [] for layer_name, v in block.items(): if 'pool' in layer_name: layer = nn.MaxPool2d(kernel_size=v[0], stride=v[1], paddin...
null
7,764
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random def renew_doc(data_file, table): # header markdown = [] with open(data_file, 'r') as f: lines = f.readlines() for line in lines: columns = [ column.strip() for column in line.split("|") ] ...
null
7,765
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random TABLE_MAP = { "macos": "./data/macos.md", "ios": "./data/ios.md", "ios_game": "./data/ios_game.md", "chinese": "./data/chinese.md", "signup": "./data/signup.md" } README_TEMPLATE_FILE = "./data/README.template" def re...
null
7,766
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random FULL_PATTERN = re.compile(r"版本的测试员已满|This beta is full") NO_PATTERN = re.compile(r"版本目前不接受任何新测试员|This beta isn't accepting any new testers right now")stFlight - Apple") APP_NAME_CH_PATTERN = re.compile(r"加入 Beta 版“(.+)” - TestFlight - App...
null
7,767
import sqlite3 import datetime, re, os, sys INVALID_DATA = [] TODAY = datetime.datetime.utcnow().date().strftime("%Y-%m-%d") def process(data_file, table): conn = sqlite3.connect('../db/sqlite3.db') cur = conn.cursor() with open(data_file, 'r') as f: lines = f.readlines() data_flag = False...
null
7,768
import sqlite3 import datetime, re, os, sys INVALID_DATA = [] def other_links(): with open('./data/signup.md', 'r+') as f: exists_data = f.readlines() temp = [] for line in INVALID_DATA: if line not in exists_data: temp.append(line) f.writelines(temp) ...
null
7,769
import sqlite3 import re, os, sys def renew_doc(data_file, table): # header markdown = [] with open(data_file, 'r') as f: lines = f.readlines() for line in lines: columns = [ column.strip() for column in line.split("|") ] markdown.append(line) if len(colu...
null
7,770
import sqlite3 import re, os, sys TABLE_MAP = { "macos": "./data/macos.md", "ios": "./data/ios.md", "ios_game": "./data/ios_game.md", "chinese": "./data/chinese.md", "signup": "./data/signup.md" } README_TEMPLATE_FILE = "./data/README.template" def renew_readme(): template = "" with open(RE...
null
7,771
import sqlite3 import re, os, sys def renew_doc(data_file, table): # header markdown = [] with open(data_file, 'r') as f: lines = f.readlines() for line in lines: columns = [ column.strip() for column in line.split("|") ] markdown.append(line) if len(colu...
null
7,773
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random from fake_user_agent import user_agent import math def get_old_status(table): conn = sqlite3.connect('../db/sqlite3.db') cur = conn.cursor() res = cur.execute(f"SELECT testflight_link, status FROM {table};") res_dict = {}...
null
7,774
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random from fake_user_agent import user_agent import math TODAY = datetime.datetime.utcnow().date().strftime("%Y-%m-%d") def update_status(table, change_list): conn = sqlite3.connect('../db/sqlite3.db') cur = conn.cursor() for updat...
null
7,775
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random from fake_user_agent import user_agent import math def renew_doc(data_file, table): # header markdown = [] with open(data_file, 'r') as f: lines = f.readlines() for line in lines: columns = [ colum...
null
7,776
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random from fake_user_agent import user_agent import math TABLE_MAP = { "macos": "./data/macos.md", "ios": "./data/ios.md", "ios_game": "./data/ios_game.md", "chinese": "./data/chinese.md", "signup": "./data/signup.md" } READ...
null
7,777
import sqlite3 import asyncio import aiohttp import re, os, sys, datetime, random from fake_user_agent import user_agent import math FULL_PATTERN = re.compile(r"版本的测试员已满|This beta is full") NO_PATTERN = re.compile(r"版本目前不接受任何新测试员|This beta isn't accepting any new testers right now") UA_NUM = 0 async def check_status(s...
null
7,778
import math import warnings from typing import Optional import torch import torch.nn as nn from einops import rearrange from packaging import version from torch import nn from .norm import LPLayerNorm def scaled_multihead_dot_product_attention( query, key, value, n_heads, past_key_value=None, s...
null
7,779
import math import warnings from typing import Optional import torch import torch.nn as nn from einops import rearrange from packaging import version from torch import nn from .norm import LPLayerNorm def _reset_is_causal(num_query_tokens: int, num_key_tokens: int, original_is_causal: bool): if original_is_causal a...
null
7,780
import math import warnings from typing import Optional import torch import torch.nn as nn from einops import rearrange from packaging import version from torch import nn from .norm import LPLayerNorm def _reset_is_causal(num_query_tokens: int, num_key_tokens: int, original_is_causal: bool): if original_is_causal a...
null