entry_point
stringlengths
1
65
original_triton_python_code
stringlengths
208
619k
optimised_triton_code
stringlengths
1.15k
275k
repo_name
stringlengths
7
115
module_name
stringlengths
1
65
synthetic
bool
1 class
uuid
int64
0
18.5k
licenses
listlengths
1
6
stars
int64
0
19.8k
sha
stringlengths
40
40
repo_link
stringlengths
72
180
SoftmaxLoss
import torch import torch.nn as nn class SoftmaxLoss(nn.Module): def __init__(self, hidden_dim, speaker_num, **kwargs): """ Softmax Loss """ super(SoftmaxLoss, self).__init__() self.fc = nn.Linear(hidden_dim, speaker_num) self.loss = nn.CrossEntropyLoss() def ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
albertvillanova/s3prl
SoftmaxLoss
false
6,165
[ "MIT" ]
1
b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
https://github.com/albertvillanova/s3prl/tree/b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
Delta
import torch import torch.nn as nn from torchaudio import transforms class Delta(nn.Module): def __init__(self, order=2, **kwargs): super(Delta, self).__init__() self.order = order self.compute_delta = transforms.ComputeDeltas(**kwargs) def forward(self, x): feats = [x] ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn from torchaudio import transforms assert_size_stride = tor...
albertvillanova/s3prl
Delta
false
6,166
[ "MIT" ]
1
b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
https://github.com/albertvillanova/s3prl/tree/b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
SAP
import torch import torch.nn as nn class SelfAttentionPooling(nn.Module): """ Implementation of SelfAttentionPooling Original Paper: Self-Attention Encoding and Pooling for Speaker Recognition https://arxiv.org/pdf/2008.01077v1.pdf """ def __init__(self, input_dim): super(SelfAttenti...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
albertvillanova/s3prl
SAP
false
6,167
[ "MIT" ]
1
b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
https://github.com/albertvillanova/s3prl/tree/b127ade4ed2f80a1027901bbd2f204b4fb1aaf03
LargeMarginCosLoss
import torch from torch import nn def cosine_sim(x1, x2, dim=1, eps=1e-08): ip = torch.mm(x1, x2.t()) w1 = torch.norm(x1, 2, dim) w2 = torch.norm(x2, 2, dim) return ip / torch.ger(w1, w2).clamp(min=eps) class LargeMarginCosLoss(nn.Module): """ CosFace: Large Margin Cosine Loss for Deep Face ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
alexalex222/classification_loss
LargeMarginCosLoss
false
6,168
[ "MIT" ]
1
a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
https://github.com/alexalex222/classification_loss/tree/a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
ParallelAttention
import torch import torch.nn as nn class ParallelAttention(nn.Module): def __init__(self, embedding_size, hidden_size): super().__init__() self.hidden_size = hidden_size self.embedding_size = embedding_size self.ques_linear = nn.Linear(self.embedding_size, self.hidden_size) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
alasin/vqa_pytorch
ParallelAttention
false
6,169
[ "MIT" ]
1
8a311226d8eea56ef79f6be3c864ec05768e2895
https://github.com/alasin/vqa_pytorch/tree/8a311226d8eea56ef79f6be3c864ec05768e2895
SpatialAttention
import torch import torch.nn as nn import torch.nn.functional as F class SpatialAttention(nn.Module): def __init__(self, kernel_size=7): super(SpatialAttention, self).__init__() assert kernel_size in (3, 7), 'kernel size must be 3 or 7' padding = 3 if kernel_size == 7 else 1 self....
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
alexchungio/Scene-Classification-Competition
SpatialAttention
false
6,170
[ "Apache-2.0" ]
1
d936667ceba1c0b8f90eb266019f43ff27767534
https://github.com/alexchungio/Scene-Classification-Competition/tree/d936667ceba1c0b8f90eb266019f43ff27767534
ScaledL2Norm
import torch import torch.nn as nn import torch.nn.functional as F class ScaledL2Norm(nn.Module): def __init__(self, in_channels, initial_scale): super(ScaledL2Norm, self).__init__() self.in_channels = in_channels self.scale = nn.Parameter(torch.Tensor(in_channels)) self.initial_s...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert...
alejodosr/adaptive-inattention
ScaledL2Norm
false
6,171
[ "MIT" ]
1
ad1c883081e5248704be5ce5c4baa24b2eda1c59
https://github.com/alejodosr/adaptive-inattention/tree/ad1c883081e5248704be5ce5c4baa24b2eda1c59
BottleneckLSTMCell
import logging import torch import torch.nn as nn from torch.autograd import Variable class BottleneckLSTMCell(nn.Module): """ Creates a LSTM layer cell Arguments: input_channels : variable used to contain value of number of channels in input hidden_channels : variable used to contain value of...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import logging import torch.n...
alejodosr/adaptive-inattention
BottleneckLSTMCell
false
6,172
[ "MIT" ]
1
ad1c883081e5248704be5ce5c4baa24b2eda1c59
https://github.com/alejodosr/adaptive-inattention/tree/ad1c883081e5248704be5ce5c4baa24b2eda1c59
AndMLP
import torch import torch.nn as nn import torch.nn.functional as F class AndMLP(nn.Module): def __init__(self, n_layers, entity_dim): super(AndMLP, self).__init__() self.n_layers = n_layers self.layers = [] for i in range(1, self.n_layers + 1): setattr(self, 'and_layer...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
amayuelas/NNKGReasoning
AndMLP
false
6,173
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
dce_loss
import torch from torch import nn class dce_loss(nn.Module): def __init__(self, n_classes, feat_dim, init_weight=True): super(dce_loss, self).__init__() self.n_classes = n_classes self.feat_dim = feat_dim self.centers = nn.Parameter(torch.randn(self.feat_dim, self. n_c...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_st...
alexalex222/classification_loss
dce_loss
false
6,174
[ "MIT" ]
1
a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
https://github.com/alexalex222/classification_loss/tree/a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
Boom
import torch import torch.nn as nn class Boom(nn.Module): def __init__(self, d_model, dim_feedforward=2048, dropout=0.1, shortcut =False, output_size=512): super(Boom, self).__init__() self.linear1 = nn.Linear(d_model, dim_feedforward) self.dropout = nn.Dropout(dropout) if dropout...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
alisafaya/char-rnn.pytorch
Boom
false
6,175
[ "MIT" ]
1
473538d9f4d57a3206dccef22f7e03826c398cfb
https://github.com/alisafaya/char-rnn.pytorch/tree/473538d9f4d57a3206dccef22f7e03826c398cfb
CenterLoss
import torch from torch import nn class CenterLoss(nn.Module): """Center loss. Reference: Wen et al. A Discriminative Feature Learning Approach for Deep Face Recognition. ECCV 2016. Args: num_classes (int): number of classes. feat_dim (int): feature dimension. """ def __init...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empt...
alexalex222/classification_loss
CenterLoss
false
6,176
[ "MIT" ]
1
a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
https://github.com/alexalex222/classification_loss/tree/a61617e0c0d5ecf6e0ff388305dd9f3eaa5cbf94
PearsonCorrelation
import torch import torch.nn as nn class PearsonCorrelation(nn.Module): """ Module for measuring Pearson correlation. Given samples (x, y), the Pearson correlation coefficient is given by: .. math:: r = rac{{}\\sum_{i=1}^{n} (x_i - \\overline{x})(y_i - \\overline{y})} {\\sqrt{\\sum_{i...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert...
alexhepburn/expert
PearsonCorrelation
false
6,177
[ "BSD-3-Clause" ]
1
546f7452ced2213ef91e5ce6e7456a1668dd9f95
https://github.com/alexhepburn/expert/tree/546f7452ced2213ef91e5ce6e7456a1668dd9f95
ThreeLayerCNN
import torch import torch.utils.data class ThreeLayerCNN(torch.nn.Module): """ Input: 128x128 face image (eye aligned). Output: 1-D tensor with 2 elements. Used for binary classification. Parameters: Number of conv layers: 3 Number of fully connected layers: 2 """ def __init__...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.utils.data asser...
aleb/pipelines
ThreeLayerCNN
false
6,178
[ "Apache-2.0" ]
1
2181b2fb8bdd6cd93e7d677b9840ed1b58a83a85
https://github.com/aleb/pipelines/tree/2181b2fb8bdd6cd93e7d677b9840ed1b58a83a85
BCELovaszLoss
import torch import numpy as np from torch import nn import torch.nn.functional as F from torch.autograd import Variable def flatten_binary_scores(scores, labels, ignore=None): """ Flattens predictions in the batch (binary case) Remove labels equal to 'ignore' """ scores = scores.view(-1) labe...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import nump...
amitkumarj441/TGS_Kaggle
BCELovaszLoss
false
6,179
[ "MIT" ]
1
a4f613046cc36f3f6dbec28adb35f97a63c2a994
https://github.com/amitkumarj441/TGS_Kaggle/tree/a4f613046cc36f3f6dbec28adb35f97a63c2a994
TorchGloVeLoss
import torch import torch.nn as nn import torch.utils.data class TorchGloVeLoss(nn.Module): def __init__(self): super().__init__() self.reduction = 'sum' def forward(self, diffs, weights): return torch.sum(0.5 * torch.mul(weights, diffs ** 2)) def get_inputs(): return [torch.ra...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn import torch.utils.data assert_size_stride = torch._C._dynamo.guard...
ammarhusain/cs224u
TorchGloVeLoss
false
6,180
[ "Apache-2.0" ]
1
bbdb0aaa6b7437481e2e1fab8e12bbf1996eecd1
https://github.com/ammarhusain/cs224u/tree/bbdb0aaa6b7437481e2e1fab8e12bbf1996eecd1
BoxOffsetIntersection
import torch import torch.nn as nn import torch.nn.functional as F class BoxOffsetIntersection(nn.Module): def __init__(self, dim): super(BoxOffsetIntersection, self).__init__() self.dim = dim self.layer1 = nn.Linear(self.dim, self.dim) self.layer2 = nn.Linear(self.dim, self.dim) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
amayuelas/NNKGReasoning
BoxOffsetIntersection
false
6,181
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
HME
import numpy import torch class HME(torch.nn.Module): def __init__(self, in_features, out_features, depth, projection='linear'): super(HME, self).__init__() self.proj = projection self.depth = depth self.in_features = in_features self.out_features = out_features se...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import numpy assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
alper111/hmog
HME
false
6,182
[ "MIT" ]
1
556da11600c97bcb075a0f19ffc284120d9789d2
https://github.com/alper111/hmog/tree/556da11600c97bcb075a0f19ffc284120d9789d2
ME
import torch class ME(torch.nn.Module): def __init__(self, in_features, out_features, n_leaf, projection= 'linear', dropout=0.0): super(ME, self).__init__() self.proj = projection self.n_leaf = n_leaf self.in_features = in_features self.out_features = out_features ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
alper111/hmog
ME
false
6,183
[ "MIT" ]
1
556da11600c97bcb075a0f19ffc284120d9789d2
https://github.com/alper111/hmog/tree/556da11600c97bcb075a0f19ffc284120d9789d2
CenterIntersection
import torch import torch.nn as nn import torch.nn.functional as F class CenterIntersection(nn.Module): def __init__(self, dim): super(CenterIntersection, self).__init__() self.dim = dim self.layer1 = nn.Linear(self.dim, self.dim) self.layer2 = nn.Linear(self.dim, self.dim) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
amayuelas/NNKGReasoning
CenterIntersection
false
6,184
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
LinearZeros
import torch from torch import nn class LinearZeros(nn.Linear): def __init__(self, in_channels, out_channels, logscale_factor=3): super().__init__(in_channels, out_channels) self.logscale_factor = logscale_factor self.register_parameter('logs', nn.Parameter(torch.zeros(out_channels)) ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math from torch im...
americast/glow-pytorch
LinearZeros
false
6,185
[ "MIT" ]
1
bbc576b96a5218417d25ae76b60f04ae24621de3
https://github.com/americast/glow-pytorch/tree/bbc576b96a5218417d25ae76b60f04ae24621de3
AndAttention
import torch import torch.nn as nn import torch.nn.functional as F class AndAttention(nn.Module): def __init__(self, n_layers, entity_dim, temperature, attn_dropout=0.1): super(AndAttention, self).__init__() self.temperature = temperature self.dropout = nn.Dropout(attn_dropout) se...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
amayuelas/NNKGReasoning
AndAttention
false
6,186
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
SpatialSEBlock
import torch from torch import nn class SpatialSEBlock(nn.Module): def __init__(self, channel): super(SpatialSEBlock, self).__init__() self.conv = nn.Conv2d(in_channels=channel, out_channels=1, kernel_size=1) self.sigmoid = nn.Sigmoid() def forward(self, x): y = s...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_st...
amitkumarj441/TGS_Kaggle
SpatialSEBlock
false
6,187
[ "MIT" ]
1
a4f613046cc36f3f6dbec28adb35f97a63c2a994
https://github.com/amitkumarj441/TGS_Kaggle/tree/a4f613046cc36f3f6dbec28adb35f97a63c2a994
BAP
import torch import torch.nn as nn class BAP(nn.Module): def __init__(self, pool='GAP'): super(BAP, self).__init__() assert pool in ['GAP', 'GMP'] if pool == 'GAP': self.pool = nn.AdaptiveAvgPool2d(1) else: self.pool = nn.AdaptiveMaxPool2d(1) def forwa...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
amobiny/hide_and_seek
BAP
false
6,188
[ "MIT" ]
1
e298d9a352a6ee58e9beedf15ef3d700473b7f27
https://github.com/amobiny/hide_and_seek/tree/e298d9a352a6ee58e9beedf15ef3d700473b7f27
BetaIntersection
import torch import torch.nn as nn import torch.nn.functional as F class BetaIntersection(nn.Module): def __init__(self, dim): super(BetaIntersection, self).__init__() self.dim = dim self.layer1 = nn.Linear(2 * self.dim, 2 * self.dim) self.layer2 = nn.Linear(2 * self.dim, self.dim...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
amayuelas/NNKGReasoning
BetaIntersection
false
6,189
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
TorchGloVeModel
import torch import torch.nn as nn import torch.utils.data from torch.nn.init import xavier_uniform_ class TorchGloVeModel(nn.Module): def __init__(self, n_words, embed_dim): super().__init__() self.n_words = n_words self.embed_dim = embed_dim self.W = self._init_weights(self.n_wo...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn import torch.utils.data from torch.nn.init import xavier_u...
ammarhusain/cs224u
TorchGloVeModel
false
6,190
[ "Apache-2.0" ]
1
bbdb0aaa6b7437481e2e1fab8e12bbf1996eecd1
https://github.com/ammarhusain/cs224u/tree/bbdb0aaa6b7437481e2e1fab8e12bbf1996eecd1
MixerBlock
import torch import torch.nn as nn import torch.nn.functional as F class MlpBlock(nn.Module): def __init__(self, features, hidden_dim): super().__init__() self.hidden_dim = hidden_dim self.features = features self.fc1 = nn.Linear(self.features, self.hidden_dim) self.fc2 = ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
amayuelas/NNKGReasoning
MixerBlock
false
6,191
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
SampaddingConv1D
import torch import torch.nn as nn class SampaddingConv1D(nn.Module): def __init__(self, in_channels, out_channels, kernel_size, use_bias=True): super(SampaddingConv1D, self).__init__() self.use_bias = use_bias self.padding = nn.ConstantPad1d((int((kernel_size - 1) / 2), int( ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
amoonfana/Knowledge_Distillation
SampaddingConv1D
false
6,192
[ "Apache-2.0" ]
1
1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
https://github.com/amoonfana/Knowledge_Distillation/tree/1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
ChannelPool
import torch import torch.nn as nn import torch.nn.functional as F class ChannelPool(nn.MaxPool1d): def forward(self, X): X = X.permute(1, 2, 0) pooled = F.max_pool1d(X, self.kernel_size) pooled = pooled.permute(2, 0, 1).squeeze(0) return pooled def get_inputs(): return [tor...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
ananyaganesh/ftmp
ChannelPool
false
6,193
[ "MIT" ]
1
9ee23939f0c1da854846b8ce1a9abe4e9b377031
https://github.com/ananyaganesh/ftmp/tree/9ee23939f0c1da854846b8ce1a9abe4e9b377031
FFNet
import torch import torch.nn as nn class MyRelu(nn.Module): def __init__(self): super().__init__() self.myrelu1 = nn.ReLU() def forward(self, x): out1 = self.myrelu1(x) return out1 class FFNet(nn.Module): def __init__(self, input_size, output_size, hidden_size): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
amilanpathirana/FeedForwardNet
FFNet
false
6,194
[ "MIT" ]
1
bdf0ebe3f80233fe970e4c60754d0ffe13cadbe1
https://github.com/amilanpathirana/FeedForwardNet/tree/bdf0ebe3f80233fe970e4c60754d0ffe13cadbe1
SampaddingMaxPool1D
import torch import torch.nn as nn class SampaddingMaxPool1D(nn.Module): def __init__(self, pooling_size, stride): super(SampaddingMaxPool1D, self).__init__() self.pooling_size = pooling_size self.stride = stride self.padding = nn.ConstantPad1d((int((pooling_size - 1) / 2), int( ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
amoonfana/Knowledge_Distillation
SampaddingMaxPool1D
false
6,195
[ "Apache-2.0" ]
1
1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
https://github.com/amoonfana/Knowledge_Distillation/tree/1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
CMVN
import torch import torch.nn as nn class CMVN(nn.Module): __constants__ = ['mode', 'dim', 'eps'] def __init__(self, mode='global', dim=2, eps=1e-10): super(CMVN, self).__init__() if mode != 'global': raise NotImplementedError( 'Only support global mean variance nor...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
ana-kuznetsova/s3prl
CMVN
false
6,196
[ "Apache-2.0" ]
1
1fd3309f693f9cd765f56b12375ed0e7c41ef093
https://github.com/ana-kuznetsova/s3prl/tree/1fd3309f693f9cd765f56b12375ed0e7c41ef093
PositionalEncoding
import torch from torch import nn import torch.nn import torch.optim class PositionalEncoding(nn.Module): """ A special, non-learnable positional encoding for handling variable (possibly longer) lengths of inputs. We simply add an ordinal number as an additional dimension for the input embeddings, and...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch import nn import t...
ananthsub/ReAgent
PositionalEncoding
false
6,197
[ "BSD-3-Clause" ]
1
92f223a135b8fbc0942a217acb117ad0935897a3
https://github.com/ananthsub/ReAgent/tree/92f223a135b8fbc0942a217acb117ad0935897a3
ToTensor
from torch.nn import Module import torch class ToTensor(Module): def __init__(self): super(ToTensor, self).__init__() def forward(self, x): x = x / 255 return x def get_inputs(): return [torch.rand([4, 4, 4, 4])] def get_init_inputs(): return [[], {}]
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch.nn import Module assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._em...
alinavalinav/finn
ToTensor
false
6,198
[ "BSD-3-Clause" ]
1
e443a5859066a410a63c08dcfec4a90527ca24be
https://github.com/alinavalinav/finn/tree/e443a5859066a410a63c08dcfec4a90527ca24be
Discriminator2d
import torch import torch.nn as nn import torch.utils.data import torch class Discriminator2d(nn.Module): def __init__(self, ngpu, wd, nc_d): super(Discriminator2d, self).__init__() self.ngpu = ngpu self.conv0 = nn.Conv2d(nc_d, 2 ** (wd - 4), 4, 2, 1) self.conv1 = nn.Conv2d(2 ** (...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn import ...
amirDahari1/super-res
Discriminator2d
false
6,199
[ "MIT" ]
1
2a93a20d65c570a5398caef65957fb612c3581c8
https://github.com/amirDahari1/super-res/tree/2a93a20d65c570a5398caef65957fb612c3581c8
KD
import torch import torch.nn as nn import torch.nn.functional as F class KD(nn.Module): def __init__(self, alpha, T): super(KD, self).__init__() self.alpha = alpha self.T = T def forward(self, output_stu, output_tch, label): loss_stu = F.cross_entropy(output_stu, label) ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
amoonfana/Knowledge_Distillation
KD
false
6,200
[ "Apache-2.0" ]
1
1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
https://github.com/amoonfana/Knowledge_Distillation/tree/1ee814a8f70ae00d17e1e1ee778d5420d96c43c4
handpose_model
import torch from collections import OrderedDict 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], padding=v[2]) layers.append((layer_name, l...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from collections import Order...
alanlee-chn/handpose-est
handpose_model
false
6,201
[ "MIT" ]
1
241a6beb45e045e65a328aade22ce536f4dcd893
https://github.com/alanlee-chn/handpose-est/tree/241a6beb45e045e65a328aade22ce536f4dcd893
FeedForward
import torch import torch.nn as nn import torch.nn.functional as F class FeedForward(nn.Module): def __init__(self, d_model, d_ff=2048, dropout=0.1): super().__init__() self.linear_1 = nn.Linear(d_model, d_ff) self.dropout = nn.Dropout(dropout) self.linear_2 = nn.Linear(d_ff, d_mo...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
and-smith/Vac-Scholar-Curb-GAN
FeedForward
false
6,202
[ "MIT" ]
1
142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
https://github.com/and-smith/Vac-Scholar-Curb-GAN/tree/142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
VAE
import torch from torch.nn import functional as F import torch.nn as nn import torch.utils.data class VAE(nn.Module): def __init__(self, dim, middle=400, bottleneck=100): super(VAE, self).__init__() self.dim = dim self.fc1 = nn.Linear(dim, middle) self.fc21 = nn.Linear(middle, bot...
import torch from torch import device from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from...
anandijain/audio
VAE
false
6,203
[ "MIT" ]
1
1990de57ebc760cf6c5cc7132119b389cfd2dbfb
https://github.com/anandijain/audio/tree/1990de57ebc760cf6c5cc7132119b389cfd2dbfb
SelfAttentionPooling
import torch import torch.nn as nn class SelfAttentionPooling(nn.Module): """ Implementation of SelfAttentionPooling Original Paper: Self-Attention Encoding and Pooling for Speaker Recognition https://arxiv.org/pdf/2008.01077v1.pdf """ def __init__(self, input_dim): super(SelfAttentio...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
ana-kuznetsova/s3prl
SelfAttentionPooling
false
6,204
[ "Apache-2.0" ]
1
1fd3309f693f9cd765f56b12375ed0e7c41ef093
https://github.com/ana-kuznetsova/s3prl/tree/1fd3309f693f9cd765f56b12375ed0e7c41ef093
down_right_shifted_conv2d
import torch import torch.nn as nn from torch.nn.utils import weight_norm as wn def right_shift(x, pad=None): xs = [int(y) for y in x.size()] x = x[:, :, :, :xs[3] - 1] pad = nn.ZeroPad2d((1, 0, 0, 0)) if pad is None else pad return pad(x) class down_right_shifted_conv2d(nn.Module): def __init_...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
andiac/pixel-cnn-pp
down_right_shifted_conv2d
false
6,205
[ "MIT" ]
1
3ba856320e40208cbb6e9cac3e66a739f148903e
https://github.com/andiac/pixel-cnn-pp/tree/3ba856320e40208cbb6e9cac3e66a739f148903e
SuperPointNet
import torch class SuperPointNet(torch.nn.Module): """ Pytorch definition of SuperPoint Network. """ def __init__(self): super(SuperPointNet, self).__init__() self.relu = torch.nn.ReLU(inplace=True) self.pool = torch.nn.MaxPool2d(kernel_size=2, stride=2) c1, c2, c3, c4, c5,...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
albutko/vlb
SuperPointNet
false
6,206
[ "BSD-2-Clause" ]
1
437245c0991948eeb36a277937a7e67d389041e4
https://github.com/albutko/vlb/tree/437245c0991948eeb36a277937a7e67d389041e4
down_shifted_conv2d
import torch import torch.nn as nn from torch.nn.utils import weight_norm as wn def down_shift(x, pad=None): xs = [int(y) for y in x.size()] x = x[:, :, :xs[2] - 1, :] pad = nn.ZeroPad2d((0, 0, 1, 0)) if pad is None else pad return pad(x) class down_shifted_conv2d(nn.Module): def __init__(self,...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
andiac/pixel-cnn-pp
down_shifted_conv2d
false
6,207
[ "MIT" ]
1
3ba856320e40208cbb6e9cac3e66a739f148903e
https://github.com/andiac/pixel-cnn-pp/tree/3ba856320e40208cbb6e9cac3e66a739f148903e
ContrastiveLoss
import torch import torch.nn as nn import torch.nn.functional as F class ContrastiveLoss(nn.Module): """ Contrastive loss Takes embeddings of two samples and a target label == 1 if samples are from the same class and label == 0 otherwise. Code from https://github.com/adambielski/siamese-triplet""" ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert...
anish-lu-yihe/abcpy
ContrastiveLoss
false
6,208
[ "BSD-3-Clause-Clear" ]
1
be58367c4d7e38ee696238e3d8405e8abe2defb7
https://github.com/anish-lu-yihe/abcpy/tree/be58367c4d7e38ee696238e3d8405e8abe2defb7
LabelSmoothingBCE
import torch import torch.nn as nn import torch.utils.data import torch.utils.data.distributed class LabelSmoothingBCE(nn.Module): def __init__(self, smoothing=0.0): super(LabelSmoothingBCE, self).__init__() self.criterion = nn.BCEWithLogitsLoss(reduction='none') self.confidence = 1.0 - s...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
anoushkt/craftassist
LabelSmoothingBCE
false
6,209
[ "MIT" ]
1
c200af65e52e800f0f0cc540fe836b644383349d
https://github.com/anoushkt/craftassist/tree/c200af65e52e800f0f0cc540fe836b644383349d
SmoothL1Loss
import torch import torch.utils.data def smooth_l1_loss(input, target, beta=1.0 / 9, size_average=True): """ very similar to the smooth_l1_loss from pytorch, but with the extra beta parameter """ n = torch.abs(input - target) cond = n < beta loss = torch.where(cond, 0.5 * n ** 2 / beta, n ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.utils.dat...
anslt/retinamask
SmoothL1Loss
false
6,210
[ "MIT" ]
1
12b58febfd0a5ed6914796a4a3db60c2a8181370
https://github.com/anslt/retinamask/tree/12b58febfd0a5ed6914796a4a3db60c2a8181370
nin
import torch import torch.nn as nn from torch.nn.utils import weight_norm as wn class nin(nn.Module): def __init__(self, dim_in, dim_out): super(nin, self).__init__() self.lin_a = wn(nn.Linear(dim_in, dim_out)) self.dim_out = dim_out def forward(self, x): """ a network in net...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
andiac/pixel-cnn-pp
nin
false
6,211
[ "MIT" ]
1
3ba856320e40208cbb6e9cac3e66a739f148903e
https://github.com/andiac/pixel-cnn-pp/tree/3ba856320e40208cbb6e9cac3e66a739f148903e
UpsamplingBlock
import torch import torch.utils.data import torch import torch.nn as nn class UpsamplingBlock(nn.Module): def __init__(self, input_nc, output_nc, kernel, stride, pad): """ Single block of upsampling operation Input: - int input_nc : Input number of channels - int outpu...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.utils.data impor...
andrewjong/Guided-pix2pix
UpsamplingBlock
false
6,212
[ "BSD-3-Clause" ]
1
0c6a7b5fde50ad7ea4fb20a6136fc6cb6c4e5542
https://github.com/andrewjong/Guided-pix2pix/tree/0c6a7b5fde50ad7ea4fb20a6136fc6cb6c4e5542
MultiHeadAttention
import math import torch import torch.nn as nn import torch.nn.functional as F def attention(q, k, v, d_k, mask=None, dropout=None): scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k) if mask is not None: mask = mask.unsqueeze(1) scores = scores.masked_fill(mask == 0, -1000000000.0...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
and-smith/Vac-Scholar-Curb-GAN
MultiHeadAttention
false
6,213
[ "MIT" ]
1
142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
https://github.com/and-smith/Vac-Scholar-Curb-GAN/tree/142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
HighwayNetwork
import torch import torch.nn as nn import torch.utils.data import torch.utils.data.distributed class HighwayNetwork(nn.Module): def __init__(self, in_dim, out_dim): super(HighwayNetwork, self).__init__() self.gate_proj = nn.Linear(in_dim, out_dim) self.lin_proj = nn.Linear(in_dim, out_dim...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn import ...
anoushkt/craftassist
HighwayNetwork
false
6,214
[ "MIT" ]
1
c200af65e52e800f0f0cc540fe836b644383349d
https://github.com/anoushkt/craftassist/tree/c200af65e52e800f0f0cc540fe836b644383349d
HighwayLayer
import torch import torch.nn as nn import torch.utils.data import torch.utils.data.distributed def my_xavier_init(m, gain=1): for p in m.parameters(): if p.dim() > 1: nn.init.xavier_uniform_(p, gain) else: nn.init.constant_(p, 0) class HighwayLayer(torch.nn.Module): ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
anoushkt/craftassist
HighwayLayer
false
6,215
[ "MIT" ]
1
c200af65e52e800f0f0cc540fe836b644383349d
https://github.com/anoushkt/craftassist/tree/c200af65e52e800f0f0cc540fe836b644383349d
DiceLoss
import torch import torch.nn as nn class DiceLoss(nn.Module): def __init__(self): super(DiceLoss, self).__init__() self.smooth = 1.0 def forward(self, y_pred, y_true): assert y_pred.size() == y_true.size() y_pred = y_pred[:, 0].contiguous().view(-1) y_true = y_true[:,...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
anudeepsekhar/Lane-Detection-Pytorch
DiceLoss
false
6,216
[ "MIT" ]
1
cfddda8a0768cf83afd87e29d605fd58aa89df59
https://github.com/anudeepsekhar/Lane-Detection-Pytorch/tree/cfddda8a0768cf83afd87e29d605fd58aa89df59
MixtureSoftmax
import torch import torch.nn as nn def project_simplex(x): """ Project an arbitary vector onto the simplex. See [Wang & Carreira-Perpin 2013] for a description and references. """ n = x.size()[0] mu = torch.sort(x, 0, descending=True)[0] sm = 0 for j in xrange(1, n + 1): sm += ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
anuar12/deep_game_theory
MixtureSoftmax
false
6,217
[ "MIT" ]
1
1debe5a498fe5f017f2791965a5e529b0dfb0529
https://github.com/anuar12/deep_game_theory/tree/1debe5a498fe5f017f2791965a5e529b0dfb0529
vggUpconv
import torch import torch.nn as nn class vggUpconv(nn.Module): """Some Information about vggUpconv""" def __init__(self, in_ch, out_ch, upsample=True): super(vggUpconv, self).__init__() if upsample: self.upsample = nn.Upsample(scale_factor=2, mode='bilinear') else: ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
anudeepsekhar/Lane-Detection-Pytorch
vggUpconv
false
6,218
[ "MIT" ]
1
cfddda8a0768cf83afd87e29d605fd58aa89df59
https://github.com/anudeepsekhar/Lane-Detection-Pytorch/tree/cfddda8a0768cf83afd87e29d605fd58aa89df59
MCCRLoss
import torch from torch import nn class MCCRLoss(nn.Module): """Maximum Correntropy Criterion Induced Losses for Regression(MCCR) Loss""" def __init__(self, sigma=1.0): super().__init__() assert sigma > 0 self.sigma2 = sigma ** 2 def forward(self, _input: 'torch.Tensor', _target:...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math from torch import nn a...
appleparan/mise.py
MCCRLoss
false
6,219
[ "MIT" ]
1
a77ea51be37a739928600c66d168d69b78bc0c4b
https://github.com/appleparan/mise.py/tree/a77ea51be37a739928600c66d168d69b78bc0c4b
OrMixer
import torch import torch.nn as nn import torch.nn.functional as F class MlpBlock(nn.Module): def __init__(self, features, hidden_dim): super().__init__() self.hidden_dim = hidden_dim self.features = features self.fc1 = nn.Linear(self.features, self.hidden_dim) self.fc2 = ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
amayuelas/NNKGReasoning
OrMixer
false
6,220
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
MlpMixer
import torch import torch.nn as nn import torch.nn.functional as F class MlpBlock(nn.Module): def __init__(self, features, hidden_dim): super().__init__() self.hidden_dim = hidden_dim self.features = features self.fc1 = nn.Linear(self.features, self.hidden_dim) self.fc2 = ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
amayuelas/NNKGReasoning
MlpMixer
false
6,221
[ "MIT" ]
1
0e3623b344fd4e3088ece897f898ddbb1f80888d
https://github.com/amayuelas/NNKGReasoning/tree/0e3623b344fd4e3088ece897f898ddbb1f80888d
Building_Block
import math import torch import torch.nn as nn import torch.nn.functional as F def attention(q, k, v, d_k, mask=None, dropout=None): scores = torch.matmul(q, k.transpose(-2, -1)) / math.sqrt(d_k) if mask is not None: mask = mask.unsqueeze(1) scores = scores.masked_fill(mask == 0, -1000000000.0...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
and-smith/Vac-Scholar-Curb-GAN
Building_Block
false
6,222
[ "MIT" ]
1
142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
https://github.com/and-smith/Vac-Scholar-Curb-GAN/tree/142bd70fdf0f1cbc4a1c20c5e58fa5b6a9dbe742
LossAttentionLayer
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data class LossAttentionLayer(nn.Module): def __init__(self): super(LossAttentionLayer, self).__init__() def forward(self, features, W_1, b_1): out_c = F.linear(features, W_1, b_1) out = out_c - out...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
apardyl/ProtoPNet
LossAttentionLayer
false
6,223
[ "MIT" ]
1
b2bbd7284bfc84a37385c0e975408c68cdf64205
https://github.com/apardyl/ProtoPNet/tree/b2bbd7284bfc84a37385c0e975408c68cdf64205
KLLoss
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.parallel import torch.utils.data def kl_loss(x, y): x = F.softmax(x.detach(), dim=1) y = F.log_softmax(y, dim=1) return torch.mean(torch.sum(x * (torch.log(x) - y), dim=1)) class KLLoss(nn.Module): def forward(self, ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
anurag1paul/pseudo_lidar
KLLoss
false
6,224
[ "MIT" ]
1
02faf327efd43c986629d0ea797b058e464c05aa
https://github.com/anurag1paul/pseudo_lidar/tree/02faf327efd43c986629d0ea797b058e464c05aa
Time2Vec
import torch from torch import nn class Time2Vec(nn.Module): """Encode time information phi and omega has k + 1 elements per each time step so, from input (batch_size, sample_size) will be ouptut (batch_size, sample_size, embed_size) Reference * https://arxiv.org/abs/1907.05321 * https:/...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math from torch im...
appleparan/mise.py
Time2Vec
false
6,225
[ "MIT" ]
1
a77ea51be37a739928600c66d168d69b78bc0c4b
https://github.com/appleparan/mise.py/tree/a77ea51be37a739928600c66d168d69b78bc0c4b
MatrixLayer
import torch import torch.nn as nn class ActionPool(nn.Module): """ Basic pooling operations. """ def __init__(self, axis, function='mean', expand=True): super(ActionPool, self).__init__() self.expand = expand self._function_name = function self._axis_name = axis ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
anuar12/deep_game_theory
MatrixLayer
false
6,226
[ "MIT" ]
1
1debe5a498fe5f017f2791965a5e529b0dfb0529
https://github.com/anuar12/deep_game_theory/tree/1debe5a498fe5f017f2791965a5e529b0dfb0529
TVLoss
import torch import torch.nn as nn from torch.nn import functional as F class TVLoss(nn.Module): def forward(self, input): input = F.pad(input, (0, 1, 0, 1), 'replicate') x_diff = input[..., :-1, 1:] - input[..., :-1, :-1] y_diff = input[..., 1:, :-1] - input[..., :-1, :-1] diff =...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
aradalienzzzz/vqgan-clip-app
TVLoss
false
6,227
[ "MIT" ]
1
f5a16d792da5ad0ede855254fe393f6b990c8e1d
https://github.com/aradalienzzzz/vqgan-clip-app/tree/f5a16d792da5ad0ede855254fe393f6b990c8e1d
StdConv2d
import torch import torch.nn as nn import torch.nn.functional as F class StdConv2d(nn.Conv2d): def forward(self, x): w = self.weight v, m = torch.var_mean(w, dim=[1, 2, 3], keepdim=True, unbiased=False) w = (w - m) / torch.sqrt(v + 1e-05) return F.conv2d(x, w, self.bias, self.stri...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
aris-mukherjee/TransUNet-modified
StdConv2d
false
6,228
[ "Apache-2.0" ]
1
185307b677fd6ee05604213c90e14e028fab476a
https://github.com/aris-mukherjee/TransUNet-modified/tree/185307b677fd6ee05604213c90e14e028fab476a
LearnedPositionalEmbedding1D
import torch from torch import nn import torch.nn import torch.autograd class LearnedPositionalEmbedding1D(nn.Module): """Adds (optionally learned) positional embeddings to the inputs.""" def __init__(self, seq_len, dim): super().__init__() self.pos_embedding = nn.Parameter(torch.zeros(1, seq...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn import torch.nn import torch.autograd assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cud...
arkel23/yuwu
LearnedPositionalEmbedding1D
false
6,229
[ "MIT" ]
1
4dcf0e18693e09a947569ddcc7cb3ff00c7c674a
https://github.com/arkel23/yuwu/tree/4dcf0e18693e09a947569ddcc7cb3ff00c7c674a
BasicBlock
import math import torch import torch.nn as nn from torch.nn.parameter import Parameter class GraphConv(nn.Module): def __init__(self, in_features, out_features, bias=False): super(GraphConv, self).__init__() self.in_features = in_features self.out_features = out_features self.wei...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import math import torch.nn a...
ardihikaru/learn-to-cluster
BasicBlock
false
6,230
[ "MIT" ]
1
d7a5ea0946f7b402f8878bfd608bf3e0dc9a26ca
https://github.com/ardihikaru/learn-to-cluster/tree/d7a5ea0946f7b402f8878bfd608bf3e0dc9a26ca
BasicBlock
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data.distributed class FilterResponseNormNd(nn.Module): def __init__(self, ndim, num_features, eps=1e-06, learnable_eps=False): """ Input Variables: ---------------- ndim: An integer indicati...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
aouedions11/SSFL-Benchmarking-Semi-supervised-Federated-Learning
BasicBlock
false
6,231
[ "MIT" ]
1
78aec81919bf95ed4677d0e0a4ebbbe3be455742
https://github.com/aouedions11/SSFL-Benchmarking-Semi-supervised-Federated-Learning/tree/78aec81919bf95ed4677d0e0a4ebbbe3be455742
Embedding
import torch import numpy as np import torch as t import torch.nn as nn import torch.utils.data class Embedding(nn.Module): """ Redefining torch.nn.Embedding (see docs for that function) """ def __init__(self, num_embeddings, embedding_dim, padding_idx=None, _weight=None): super().__i...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import numpy as np import torch as t import torch.nn as nn import torch.utils.data assert_size_stride = torch._C._dynamo.guards.assert_size_...
arjunsesh/lrr-neurips
Embedding
false
6,232
[ "MIT" ]
1
d78106daec1e729b02a0452f74a37bf004ed243c
https://github.com/arjunsesh/lrr-neurips/tree/d78106daec1e729b02a0452f74a37bf004ed243c
Attention
import torch import torch.nn.functional as F from torch import nn class Attention(nn.Module): """Attention Layer merging Encoder and Decoder Attributes: hidden_size (int): The number of features in the hidden state h Reference: * https://github.com/bentrevett/pytorch-seq2seq ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
appleparan/mise.py
Attention
false
6,233
[ "MIT" ]
1
a77ea51be37a739928600c66d168d69b78bc0c4b
https://github.com/appleparan/mise.py/tree/a77ea51be37a739928600c66d168d69b78bc0c4b
FilterResponseNormNd
import torch import torch.nn as nn import torch.utils.data.distributed class FilterResponseNormNd(nn.Module): def __init__(self, ndim, num_features, eps=1e-06, learnable_eps=False): """ Input Variables: ---------------- ndim: An integer indicating the number of dimensions of t...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math import torc...
aouedions11/SSFL-Benchmarking-Semi-supervised-Federated-Learning
FilterResponseNormNd
false
6,234
[ "MIT" ]
1
78aec81919bf95ed4677d0e0a4ebbbe3be455742
https://github.com/aouedions11/SSFL-Benchmarking-Semi-supervised-Federated-Learning/tree/78aec81919bf95ed4677d0e0a4ebbbe3be455742
PrimaryCapsules
import torch import torch.nn as nn def squash(x, dim=-1, epsilon=1e-08): norm = (x ** 2).sum(dim=dim, keepdim=True) x = norm / (norm + 1) * x / (torch.sqrt(norm) + epsilon) return x class PrimaryCapsules(nn.Module): def __init__(self, in_features, capsules_num, capsules_dim): super(PrimaryC...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
ashawkey/CapsNet.pytorch
PrimaryCapsules
false
6,235
[ "MIT" ]
1
3b796b572bbabe79cc445c35913cd3584733aedf
https://github.com/ashawkey/CapsNet.pytorch/tree/3b796b572bbabe79cc445c35913cd3584733aedf
MNL
import torch import torch.nn as nn import torch.utils.data class MNL(nn.Module): """ Implementation of MNL choice model as a Pytorch module """ def __init__(self, n): super(MNL, self).__init__() self.u = nn.Parameter(torch.nn.init.normal(torch.Tensor(n))) self.n = n se...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn ...
arjunsesh/lrr-neurips
MNL
false
6,236
[ "MIT" ]
1
d78106daec1e729b02a0452f74a37bf004ed243c
https://github.com/arjunsesh/lrr-neurips/tree/d78106daec1e729b02a0452f74a37bf004ed243c
ConcatELU
import torch import torch.nn as nn import torch.nn.functional as F class ConcatELU(nn.Module): """Activation function that applies ELU in both direction (inverted and plain). Allows non-linearity while providing strong gradients for any input (important for final convolution) """ def forward(self, x...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
ashutoshml/lightning-tutorials
ConcatELU
false
6,237
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
MLP
import torch import torch.nn as nn class SharedDropout(nn.Module): """ SharedDropout differs from the vanilla dropout strategy in that the dropout mask is shared across one dimension. Args: p (float): The probability of an element to be zeroed. Default: 0.5. batch_first (b...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
ashim95/parser
MLP
false
6,238
[ "MIT" ]
1
61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
https://github.com/ashim95/parser/tree/61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
BP
import torch import torch.nn as nn import torch.utils.data class BP(nn.Module): """ Implementation of the Bastell-Polking k-th order model as a pytorch module """ def __init__(self, n, k, d): """ Initializes a k-th order Batsell-Polking model Args: n- number of items ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
arjunsesh/lrr-neurips
BP
false
6,239
[ "MIT" ]
1
d78106daec1e729b02a0452f74a37bf004ed243c
https://github.com/arjunsesh/lrr-neurips/tree/d78106daec1e729b02a0452f74a37bf004ed243c
ScalarMix
import torch import torch.nn as nn class ScalarMix(nn.Module): """ Computes a parameterised scalar mixture of :math:`N` tensors, :math:`mixture = \\gamma * \\sum_{k}(s_k * tensor_k)` where :math:`s = \\mathrm{softmax}(w)`, with :math:`w` and :math:`\\gamma` scalar parameters. Args: n_layers (...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
ashim95/parser
ScalarMix
false
6,240
[ "MIT" ]
1
61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
https://github.com/ashim95/parser/tree/61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
CapsuleLoss
import torch import torch.nn as nn import torch.nn.functional as F class CapsuleLoss(nn.Module): def __init__(self): super(CapsuleLoss, self).__init__() def forward(self, inputs, labels, logits, recons): batch_size = inputs.shape[0] left = F.relu(0.9 - logits, inplace=True) ** 2 ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
ashawkey/CapsNet.pytorch
CapsuleLoss
false
6,241
[ "MIT" ]
1
3b796b572bbabe79cc445c35913cd3584733aedf
https://github.com/ashawkey/CapsNet.pytorch/tree/3b796b572bbabe79cc445c35913cd3584733aedf
BCEIoULoss
import torch from typing import Callable from functools import partial from torch import nn import torch.distributed from torch.nn.modules.loss import * from torch.nn.modules import * from torch.optim import * from torch.optim.lr_scheduler import * import torch.backends def get_activation_fn(activation: 'str'=None): ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math from typing...
arjunshibu/catalyst
BCEIoULoss
false
6,242
[ "Apache-2.0" ]
1
7160540f09530b803e5664e57db3e951fdc4dab3
https://github.com/arjunshibu/catalyst/tree/7160540f09530b803e5664e57db3e951fdc4dab3
Sigmoid
import torch import torch.nn as nn class ActivationFunction(nn.Module): def __init__(self): super().__init__() self.name = self.__class__.__name__ self.config = {'name': self.name} class Sigmoid(ActivationFunction): def forward(self, x): return 1 / (1 + torch.exp(-x)) def...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
ashutoshml/lightning-tutorials
Sigmoid
false
6,243
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
L2Norm
import torch import torch.nn as nn class L2Norm(nn.Module): def __init__(self, n_channels, scale=1.0): super(L2Norm, self).__init__() self.n_channels = n_channels self.scale = scale self.eps = 1e-10 self.weight = nn.Parameter(torch.Tensor(self.n_channels)) self.wei...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
ashuk203/face-alignment
L2Norm
false
6,244
[ "BSD-3-Clause" ]
1
1f6452ae05ede0db9bbc48331d67d8b239fa9994
https://github.com/ashuk203/face-alignment/tree/1f6452ae05ede0db9bbc48331d67d8b239fa9994
Biaffine
import torch import torch.nn as nn class Biaffine(nn.Module): """ Biaffine layer for first-order scoring. This function has a tensor of weights :math:`W` and bias terms if needed. The score :math:`s(x, y)` of the vector pair :math:`(x, y)` is computed as :math:`x^T W y`, in which :math:`x` and :m...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
ashim95/parser
Biaffine
false
6,245
[ "MIT" ]
1
61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
https://github.com/ashim95/parser/tree/61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
CDM
import torch import torch.nn as nn import torch.utils.data class CDM(nn.Module): """ Implementation of the CDM choice model as a Pytorch module """ def __init__(self, n, d): """ Initializes a CDM model Args: n- number of items in the universe d- number of dime...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers from torch._inductor.runtime....
arjunsesh/lrr-neurips
CDM
false
6,246
[ "MIT" ]
1
d78106daec1e729b02a0452f74a37bf004ed243c
https://github.com/arjunsesh/lrr-neurips/tree/d78106daec1e729b02a0452f74a37bf004ed243c
Tanh
import torch import torch.nn as nn class ActivationFunction(nn.Module): def __init__(self): super().__init__() self.name = self.__class__.__name__ self.config = {'name': self.name} class Tanh(ActivationFunction): def forward(self, x): x_exp, neg_x_exp = torch.exp(x), torch....
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
ashutoshml/lightning-tutorials
Tanh
false
6,247
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
LayerNorm
import torch import torch.nn as nn from torch.optim.lr_scheduler import * from torch.nn import Parameter from torch.nn.parameter import Parameter class LayerNorm(nn.Module): def __init__(self, hidden_size, eps=0.0001): super(LayerNorm, self).__init__() self.alpha = Parameter(torch.ones(1, 1, hidd...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn from torch.optim.lr_scheduler import * from torch.nn impo...
ashishbaghudana/san_mrc
LayerNorm
false
6,248
[ "BSD-3-Clause" ]
1
03ed7d94c735f1fe2854bb9c208385b5fde44905
https://github.com/ashishbaghudana/san_mrc/tree/03ed7d94c735f1fe2854bb9c208385b5fde44905
ReLU
import torch import torch.nn as nn class ActivationFunction(nn.Module): def __init__(self): super().__init__() self.name = self.__class__.__name__ self.config = {'name': self.name} class ReLU(ActivationFunction): def forward(self, x): return x * (x > 0).float() def get_in...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
ashutoshml/lightning-tutorials
ReLU
false
6,249
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
ELU
import torch import torch.nn as nn class ActivationFunction(nn.Module): def __init__(self): super().__init__() self.name = self.__class__.__name__ self.config = {'name': self.name} class ELU(ActivationFunction): def forward(self, x): return torch.where(x > 0, x, torch.exp(x...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert...
ashutoshml/lightning-tutorials
ELU
false
6,250
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
LeakyReLU
import torch import torch.nn as nn class ActivationFunction(nn.Module): def __init__(self): super().__init__() self.name = self.__class__.__name__ self.config = {'name': self.name} class LeakyReLU(ActivationFunction): def __init__(self, alpha=0.1): super().__init__() ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
ashutoshml/lightning-tutorials
LeakyReLU
false
6,251
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
MultiplyLuminance
import torch import torch.nn class MultiplyLuminance(torch.nn.Module): def __init__(self): super(MultiplyLuminance, self).__init__() def forward(self, color, luminance): return color * (1 + luminance) def get_inputs(): return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])] def g...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_...
ashwinpn/Computer-Vision
MultiplyLuminance
false
6,252
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
GCNLayer
import torch import torch.nn as nn class GCNLayer(nn.Module): def __init__(self, c_in, c_out): super().__init__() self.projection = nn.Linear(c_in, c_out) def forward(self, node_feats, adj_matrix): """ Args: node_feats: Tensor with node features of shape [batch_si...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
ashutoshml/lightning-tutorials
GCNLayer
false
6,253
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
FillUpLuminance
import torch import torch.nn class FillUpLuminance(torch.nn.Module): def __init__(self): super(FillUpLuminance, self).__init__() def forward(self, color, luminance): return color + (1 - color) * luminance def get_inputs(): return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])] d...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_strided_...
ashwinpn/Computer-Vision
FillUpLuminance
false
6,254
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
Triaffine
import torch import torch.nn as nn class Triaffine(nn.Module): """ Triaffine layer for second-order scoring. This function has a tensor of weights :math:`W` and bias terms if needed. The score :math:`s(x, y, z)` of the vector triple :math:`(x, y, z)` is computed as :math:`x^T z^T W y`. Usually, :...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
ashim95/parser
Triaffine
false
6,255
[ "MIT" ]
1
61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
https://github.com/ashim95/parser/tree/61e9cd6bf16dcf1aa2b9d51b3a6c04ed048b3199
AvgReducePool1d
import torch from torch import nn class AvgReducePool1d(nn.Module): """A subclass of :torch_nn:`Module`. Avg Pool layer for 1D inputs. The same as :torch_nn:`AvgPool1d` except that the pooling dimension is entirely reduced (i.e., `pool_size=input_length`). """ def forward(self, input: 'torch.Tens...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_str...
atif93/texar-pytorch
AvgReducePool1d
false
6,256
[ "Apache-2.0" ]
1
88163619ec69382e1bbe57fa8bce06260bfc76a2
https://github.com/atif93/texar-pytorch/tree/88163619ec69382e1bbe57fa8bce06260bfc76a2
CoSirenModule
import math import torch import torch.nn class CoSirenModule(torch.nn.Module): def __init__(self, in_features, out_features, weight_multiplier=1.0): super(CoSirenModule, self).__init__() self.linear = torch.nn.Linear(in_features, out_features // 2) init_bounds = math.sqrt(24 / in_features...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import math i...
ashwinpn/Computer-Vision
CoSirenModule
false
6,257
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
PotCoSirenModule
import torch import torch.nn class PotCoSirenModule(torch.nn.Module): def __init__(self, in_features, out_features, weight_multiplier=1.0): super(PotCoSirenModule, self).__init__() self.linear = torch.nn.Linear(in_features, out_features // 2) torch.nn.init.uniform_(self.linear.weight, a=-...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch....
ashwinpn/Computer-Vision
PotCoSirenModule
false
6,258
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
Autoencoder
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data class Autoencoder(nn.Module): def __init__(self): super(Autoencoder, self).__init__() self.conv1 = nn.Conv2d(3, 6, padding=2, kernel_size=5) self.maxpool1 = nn.MaxPool2d(4, stride=1, return_indices=...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime import triton_helpers import torch.nn as nn import ...
aoxolotl/slr
Autoencoder
false
6,259
[ "MIT" ]
1
20a4a9036f2dc3a61745072f89b0f5bb1cc51e1b
https://github.com/aoxolotl/slr/tree/20a4a9036f2dc3a61745072f89b0f5bb1cc51e1b
Embbed2
import torch import torch.nn class Embbed2(torch.nn.Module): def __init__(self, in_features, out_features, weight_multiplier=1.0): super(Embbed2, self).__init__() self.b = 2.0 ** torch.linspace(0, weight_multiplier, out_features // in_features) - 1 self.b = torch.nn.Parameter(...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import torch....
ashwinpn/Computer-Vision
Embbed2
false
6,260
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
SkipModule
import torch import torch.nn class SkipModule(torch.nn.Module): def __init__(self, in_features, out_features, activation=torch.nn.ReLU()): super(SkipModule, self).__init__() self.linear1 = torch.nn.Linear(in_features, out_features, activation) self.linear2 = torch.nn.Linear(out_features, ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream import torch.nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride ...
ashwinpn/Computer-Vision
SkipModule
false
6,261
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4
BarlowTwinsLoss
import torch import torch.nn as nn class BarlowTwinsLoss(nn.Module): def __init__(self, batch_size, lambda_coeff=0.005, z_dim=128): super().__init__() self.z_dim = z_dim self.batch_size = batch_size self.lambda_coeff = lambda_coeff def off_diagonal_ele(self, x): n, m ...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as ...
ashutoshml/lightning-tutorials
BarlowTwinsLoss
false
6,262
[ "Apache-2.0" ]
1
898b8b6f9852c0b80f034a3187bc1cd34dd521ce
https://github.com/ashutoshml/lightning-tutorials/tree/898b8b6f9852c0b80f034a3187bc1cd34dd521ce
L2Norm
import torch import torch.nn as nn from math import sqrt as sqrt from itertools import product as product import torch.nn.init as init class L2Norm(nn.Module): def __init__(self, n_channels, scale): super(L2Norm, self).__init__() self.n_channels = n_channels self.gamma = scale or None ...
import torch import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import libdevice import torch.nn as nn from math import sqrt as sqrt from itertools import produ...
ashwath007/amenity-detection
L2Norm
false
6,263
[ "Apache-2.0" ]
1
acb885eb4d791acc6e65237445a4fc6830e4d30c
https://github.com/ashwath007/amenity-detection/tree/acb885eb4d791acc6e65237445a4fc6830e4d30c
SirenModule
import math import torch import torch.nn class SirenModule(torch.nn.Module): def __init__(self, in_features, out_features, weight_multiplier=1.0): super(SirenModule, self).__init__() self.linear = torch.nn.Linear(in_features, out_features) init_bounds = math.sqrt(6 / in_features) * weight...
import torch from torch._inductor.select_algorithm import extern_kernels import triton import triton.language as tl from torch._inductor.runtime.triton_heuristics import grid from torch._C import _cuda_getCurrentRawStream as get_raw_stream from torch._inductor.runtime.triton_helpers import math as tl_math import math i...
ashwinpn/Computer-Vision
SirenModule
false
6,264
[ "MIT" ]
1
9dc3abfe416385171b76e2bad6872e10f36a12b4
https://github.com/ashwinpn/Computer-Vision/tree/9dc3abfe416385171b76e2bad6872e10f36a12b4