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
CustomBatchNormAutograd
import torch import torch.nn as nn class CustomBatchNormAutograd(nn.Module): """ This nn.module implements a custom version of the batch norm operation for MLPs. The operations called in self.forward track the history if the input tensors have the flag requires_grad set to True. The backward pass does not 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.triton_helpers import libdevice import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_...
askliar/deep_learning
CustomBatchNormAutograd
false
1,488
[ "MIT" ]
0
e61b2391a3258d18719bf12d9ed1404620ce6c02
https://github.com/askliar/deep_learning/tree/e61b2391a3258d18719bf12d9ed1404620ce6c02
CustomBatchNormManualModule
import torch import torch.nn as nn class CustomBatchNormManualFunction(torch.autograd.Function): """ This torch.autograd.Function implements a functional custom version of the batch norm operation for MLPs. Using torch.autograd.Function allows you to write a custom backward function. The function will be ca...
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_...
askliar/deep_learning
CustomBatchNormManualModule
false
1,489
[ "MIT" ]
0
e61b2391a3258d18719bf12d9ed1404620ce6c02
https://github.com/askliar/deep_learning/tree/e61b2391a3258d18719bf12d9ed1404620ce6c02
ScalarMix
import torch import torch.nn as nn class ScalarMix(nn.Module): """ Computes a parameterized 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...
attardi/parser
ScalarMix
false
1,490
[ "MIT" ]
0
1978ba94ba649ad0a723d71bb2ca225c7e705702
https://github.com/attardi/parser/tree/1978ba94ba649ad0a723d71bb2ca225c7e705702
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...
atticusg/cs224u
TorchGloVeLoss
false
1,491
[ "Apache-2.0" ]
0
66e0f2714e246dcb8836f706ae9ff5613c51ed34
https://github.com/atticusg/cs224u/tree/66e0f2714e246dcb8836f706ae9ff5613c51ed34
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...
atticusg/cs224u
TorchGloVeModel
false
1,492
[ "Apache-2.0" ]
0
66e0f2714e246dcb8836f706ae9ff5613c51ed34
https://github.com/atticusg/cs224u/tree/66e0f2714e246dcb8836f706ae9ff5613c51ed34
CrossEntropyLossIIT
import torch import torch.nn as nn import torch.utils.data class CrossEntropyLossIIT(nn.Module): def __init__(self): super().__init__() self.loss = nn.CrossEntropyLoss(reduction='mean') def forward(self, preds, labels): return self.loss(preds[0], labels[:, 0]) + self.loss(preds[1], ...
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 ...
atticusg/cs224u
CrossEntropyLossIIT
false
1,493
[ "Apache-2.0" ]
0
66e0f2714e246dcb8836f706ae9ff5613c51ed34
https://github.com/atticusg/cs224u/tree/66e0f2714e246dcb8836f706ae9ff5613c51ed34
ClassicModel
from _paritybench_helpers import _mock_config import torch from torch import nn class ClassicModel(nn.Module): def __init__(self, config, inpt_shp): super(ClassicModel, self).__init__() self.depth = config.depth self.nodes = config.n_qubits self.config = config self.pre_ne...
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 assert_s...
austinbeauch/QML
ClassicModel
false
1,494
[ "Apache-2.0" ]
0
4a2f5b1b0346a1a8bb0a0e6e638cf2225c4c213c
https://github.com/austinbeauch/QML/tree/4a2f5b1b0346a1a8bb0a0e6e638cf2225c4c213c
LayerNorm
import torch import torch.nn as nn import torch.nn.functional as F class LayerNorm(nn.Module): def __init__(self, num_features, eps=1e-05, affine=True): super(LayerNorm, self).__init__() self.num_features = num_features self.eps = eps self.affine = affine if self.affine: ...
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_...
audreyeternal/cyclegan
LayerNorm
false
1,495
[ "MIT" ]
0
8eb3ddb7fd0d9838862334766f1f7aaa5584c2da
https://github.com/audreyeternal/cyclegan/tree/8eb3ddb7fd0d9838862334766f1f7aaa5584c2da
BinaryLoss
import torch import torch.nn as nn import torch.nn.functional as F class BinaryLoss(nn.Module): """ Computes contrastive loss[1, 2] twice, one time for the distance between query and positive example, and another for the distance between query and negative example. Both use l2-distance. [1] http:/...
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...
atypon/specter
BinaryLoss
false
1,496
[ "Apache-2.0" ]
0
bc1ee723167cf1dbf599603e09539c1823f26c17
https://github.com/atypon/specter/tree/bc1ee723167cf1dbf599603e09539c1823f26c17
BertSelfAttention
from _paritybench_helpers import _mock_config import math import torch import torch.nn as nn import torch.utils.data class BertSelfAttention(nn.Module): def __init__(self, config): super(BertSelfAttention, self).__init__() if config.hidden_size % config.num_attention_heads != 0: raise...
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....
ashutoshbaghel/tgifqa-lxmert
BertSelfAttention
false
1,497
[ "MIT" ]
0
7969f478d20fbfbba1c0eaaf0b96891654bfcc26
https://github.com/ashutoshbaghel/tgifqa-lxmert/tree/7969f478d20fbfbba1c0eaaf0b96891654bfcc26
WCE_loss
import torch import torch.nn as nn class WCE_loss(nn.Module): def __init__(self): super(WCE_loss, self).__init__() def sum_ij(self, x): return torch.sum(torch.sum(x, dim=3), dim=2) def forward(self, pred, gt): N_fg = self.sum_ij(gt) N_bg = self.sum_ij(1 - gt) L_f...
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...
atch841/pytorch-one-shot-texture-segmentation
WCE_loss
false
1,498
[ "MIT" ]
0
8b781b861d17eb1e1e7014f54f8fd39dc10dd2b8
https://github.com/atch841/pytorch-one-shot-texture-segmentation/tree/8b781b861d17eb1e1e7014f54f8fd39dc10dd2b8
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 (bool)...
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...
attardi/parser
MLP
false
1,499
[ "MIT" ]
0
1978ba94ba649ad0a723d71bb2ca225c7e705702
https://github.com/attardi/parser/tree/1978ba94ba649ad0a723d71bb2ca225c7e705702
GELU
import torch import torch.nn as nn class GELU(nn.Module): def __init__(self): super(GELU, self).__init__() def forward(self, x): return torch.sigmoid(1.702 * x) * 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
awgansekoele/outlier-exposure
GELU
false
1,500
[ "Apache-2.0" ]
0
9557c7915fa466fc54951357519cfba27f7659ad
https://github.com/awgansekoele/outlier-exposure/tree/9557c7915fa466fc54951357519cfba27f7659ad
folder
import torch from torch import nn import torch.nn.functional as F import torch.nn.parallel class folder(nn.Module): def __init__(self): super().__init__() def forward(self, feature_map): N, _, H, W = feature_map.size() feature_map = F.unfold(feature_map, kernel_size=3, padding=1) ...
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.parallel assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C....
avinash-asink/AdelaiDet
folder
false
1,501
[ "BSD-2-Clause" ]
0
a8722579c8a724b02a36ef0f33a176ba282623fa
https://github.com/avinash-asink/AdelaiDet/tree/a8722579c8a724b02a36ef0f33a176ba282623fa
Arc2
from torch.nn import Module import torch import numpy as np class Arc2(Module): def __init__(self, num_bends): super(Arc2, self).__init__() self.num_bends = num_bends self.register_buffer('range', torch.arange(0, float(num_bends))) def a(self, t): return torch.cos(np.pi * 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.triton_helpers import math as tl_math from torch.nn import Module import numpy as np assert_size_stride = torch...
avecplezir/dnn-mode-connectivity
Arc2
false
1,502
[ "BSD-2-Clause" ]
0
9a92ca370571f542b33060f637239172a0d08bba
https://github.com/avecplezir/dnn-mode-connectivity/tree/9a92ca370571f542b33060f637239172a0d08bba
Normalize
import torch import torch.nn as nn class Normalize(nn.Module): """Normalize nn.Module. As at pytorch, simplified""" def __init__(self, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225 ], inplace=False, dtype=torch.float32): super().__init__() mean = torch.as_tensor(mean, dtype=dty...
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...
ayasyrev/pt_utils
Normalize
false
1,503
[ "Apache-2.0" ]
0
cb29b8fb4a3981248e1055979cc773f719dccdc7
https://github.com/ayasyrev/pt_utils/tree/cb29b8fb4a3981248e1055979cc773f719dccdc7
FocalLoss
import torch import torch.nn as nn import torch.nn.functional as F class FocalLoss(nn.modules.loss._WeightedLoss): def __init__(self, weight=None, gamma=2, reduction='mean'): super(FocalLoss, self).__init__(weight, reduction=reduction) self.gamma = gamma self.weight = weight def forw...
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 ...
aydindemircioglu/knee.lat
FocalLoss
false
1,504
[ "MIT" ]
0
555725222f860d4ad8fea7452685803d9e323d43
https://github.com/aydindemircioglu/knee.lat/tree/555725222f860d4ad8fea7452685803d9e323d43
DQNet
import torch import torch.nn as nn from torch.nn import functional as F class DQNet(nn.Module): """ Definition: DQNet(obs_size,act_size,hid_size=256) Regular Deep Q Network with three Linear layers """ def __init__(self, obs_size, act_size, hid_size=256): super().__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 import triton_helpers import torch.nn as nn assert_...
ayjabri/DeepRL
DQNet
false
1,505
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
Arc
from torch.nn import Module import torch import numpy as np class Arc(Module): def __init__(self, num_bends): super(Arc, self).__init__() self.num_bends = num_bends self.register_buffer('range', torch.arange(0, float(num_bends))) def a(self, t): return torch.cos(np.pi * t / 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.triton_helpers import math as tl_math from torch.nn import Module import numpy as np assert_size_stride = torch...
avecplezir/dnn-mode-connectivity
Arc
false
1,506
[ "BSD-2-Clause" ]
0
9a92ca370571f542b33060f637239172a0d08bba
https://github.com/avecplezir/dnn-mode-connectivity/tree/9a92ca370571f542b33060f637239172a0d08bba
DuelDQNet
import torch import torch.nn as nn from torch.nn import functional as F class DuelDQNet(nn.Module): """ Definition: DuelDQNet(obs_size, act_size, hid_size=256) """ def __init__(self, obs_size, act_size, hid_size=256): super().__init__() self.base = nn.Linear(obs_size, hid_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_...
ayjabri/DeepRL
DuelDQNet
false
1,507
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
TripletLossDoubleMargin
import torch import torch.nn as nn class TripletLossDoubleMargin(nn.Module): """ Triplet Loss with positive and negative margins, following the work of [1] References ---------- [1] Ho, K., Keuper, J., Pfreundt, F. J., & Keuper, M. (2021, January). Learning embeddings for image clusterin...
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...
ax-le/MusicAE
TripletLossDoubleMargin
false
1,508
[ "BSD-3-Clause" ]
0
9fdc268f6403226b990d9ae5c9f182ed0af82f98
https://github.com/ax-le/MusicAE/tree/9fdc268f6403226b990d9ae5c9f182ed0af82f98
A2CNet
import torch import torch.nn as nn from torch.nn import functional as F class A2CNet(nn.Module): """Double heads actor + critic network.""" def __init__(self, obs_size, act_size, hid_size=128): super().__init__() self.fc1 = nn.Linear(obs_size, hid_size) self.policy = nn.Linear(hid_siz...
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_...
ayjabri/DeepRL
A2CNet
false
1,509
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
BertOutAttention
from _paritybench_helpers import _mock_config import math import torch import torch.nn as nn import torch.utils.data class BertOutAttention(nn.Module): def __init__(self, config, ctx_dim=None): super().__init__() if config.hidden_size % config.num_attention_heads != 0: raise ValueErro...
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....
ashutoshbaghel/tgifqa-lxmert
BertOutAttention
false
1,510
[ "MIT" ]
0
7969f478d20fbfbba1c0eaaf0b96891654bfcc26
https://github.com/ashutoshbaghel/tgifqa-lxmert/tree/7969f478d20fbfbba1c0eaaf0b96891654bfcc26
DiceLoss
import torch import torch.nn as nn import torch.nn.functional as F class BinaryDiceLoss(nn.Module): """Dice loss of binary class Args: smooth: A float number to smooth loss, and avoid NaN error, default: 1 p: Denominator value: \\sum{x^p} + \\sum{y^p}, default: 2 predict: A tensor of 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 math as tl_math import torch.nn as nn ...
aureliedj/OilseedRapeSegmentation
DiceLoss
false
1,511
[ "MIT" ]
0
89056c3295b24354c32b6059854a3a60214c26cb
https://github.com/aureliedj/OilseedRapeSegmentation/tree/89056c3295b24354c32b6059854a3a60214c26cb
GRUCell
import torch import torch.nn as nn from torch.nn import functional as F class GRUCell(nn.Module): """Plain vanilla policy gradient network.""" def __init__(self, obs_size, act_size, hid_size=128): super().__init__() self.fc1 = nn.GRUCell(obs_size, hid_size) self.output = nn.Linear(hid...
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_...
ayjabri/DeepRL
GRUCell
false
1,512
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
ELU_1
import torch import torch.nn.functional as F import torch.nn as nn class ELU_1(nn.ELU): def __init__(self, *args, **kwargs): super(ELU_1, self).__init__(*args, **kwargs) def forward(self, input): return F.elu(input, self.alpha, self.inplace) def get_inputs(): return [torch.rand([4, 4, ...
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_...
bantiitnab/kaggle-TGS-salt-identification
ELU_1
false
1,513
[ "MIT" ]
0
8b3350278b2ee8f01ba2a0734af9514d369f3228
https://github.com/bantiitnab/kaggle-TGS-salt-identification/tree/8b3350278b2ee8f01ba2a0734af9514d369f3228
TPSELoss
import torch import torch.utils.data from torch import nn class TPSELoss(nn.Module): def __init__(self): super(TPSELoss, self).__init__() self.loss = nn.L1Loss() def forward(self, model_output): gst_embed, tpse_embed = model_output[4], model_output[5] gst_embed = gst_embed.de...
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.utils.data from torch import nn assert_size_stride = torch._...
azahed98/mellotron
TPSELoss
false
1,514
[ "BSD-3-Clause" ]
0
02998743de820e379e0c7ff44506088d6e65c693
https://github.com/azahed98/mellotron/tree/02998743de820e379e0c7ff44506088d6e65c693
ActorNet
import torch import torch.nn as nn from torch.nn import functional as F class ActorNet(nn.Module): def __init__(self, obs_size, act_size, high_action=1): super().__init__() self.high_action = high_action self.base = nn.Linear(obs_size, 400) self.fc1 = nn.Linear(400, 300) 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._inductor.runtime import triton_helpers from torch._inductor.runtime....
ayjabri/DeepRL
ActorNet
false
1,515
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
DiceLoss
import torch import torch.nn as nn def IoU(logit, truth, smooth=1): prob = torch.sigmoid(logit) intersection = torch.sum(prob * truth) union = torch.sum(prob + truth) iou = (2 * intersection + smooth) / (union + smooth) return iou class DiceLoss(nn.Module): def __init__(self, smooth=1): ...
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...
bantiitnab/kaggle-TGS-salt-identification
DiceLoss
false
1,516
[ "MIT" ]
0
8b3350278b2ee8f01ba2a0734af9514d369f3228
https://github.com/bantiitnab/kaggle-TGS-salt-identification/tree/8b3350278b2ee8f01ba2a0734af9514d369f3228
BCE_Dice
import torch import torch.nn as nn def IoU(logit, truth, smooth=1): prob = torch.sigmoid(logit) intersection = torch.sum(prob * truth) union = torch.sum(prob + truth) iou = (2 * intersection + smooth) / (union + smooth) return iou class DiceLoss(nn.Module): def __init__(self, smooth=1): ...
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...
bantiitnab/kaggle-TGS-salt-identification
BCE_Dice
false
1,517
[ "MIT" ]
0
8b3350278b2ee8f01ba2a0734af9514d369f3228
https://github.com/bantiitnab/kaggle-TGS-salt-identification/tree/8b3350278b2ee8f01ba2a0734af9514d369f3228
VanillaRNN
import torch import torch.nn as nn class VanillaRNN(nn.Module): def __init__(self, seq_length, input_dim, num_hidden, num_classes, batch_size, device='cpu'): super(VanillaRNN, self).__init__() self.seq_length = seq_length self.h_init = nn.Parameter(torch.zeros(num_hidden, 1), ...
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 ...
askliar/deep_learning
VanillaRNN
false
1,518
[ "MIT" ]
0
e61b2391a3258d18719bf12d9ed1404620ce6c02
https://github.com/askliar/deep_learning/tree/e61b2391a3258d18719bf12d9ed1404620ce6c02
MLP
import torch import torch.nn as nn class MLP(nn.Module): """ Multi-Layer Perceptron network """ def __init__(self, obs_dim, dim_latent): """ Constructor Args: obs_dim: (int) dimension of observation latent_dim: (int) dimension of output latent ...
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_...
baihuaxie/drl-lib
MLP
false
1,519
[ "MIT" ]
0
3ad344901c3bb59e0bc16bb70202d2cfd538fd77
https://github.com/baihuaxie/drl-lib/tree/3ad344901c3bb59e0bc16bb70202d2cfd538fd77
ChannelGate2d
import torch import torch.nn as nn class ChannelGate2d(nn.Module): def __init__(self, channels, reduction=2): super(ChannelGate2d, self).__init__() self.avg_pool = nn.AdaptiveAvgPool2d(1) self.fc1 = nn.Conv2d(channels, channels // reduction, kernel_size=1, padding=0) 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._inductor.runtime import triton_helpers import torch.nn as nn assert_...
bantiitnab/kaggle-TGS-salt-identification
ChannelGate2d
false
1,520
[ "MIT" ]
0
8b3350278b2ee8f01ba2a0734af9514d369f3228
https://github.com/bantiitnab/kaggle-TGS-salt-identification/tree/8b3350278b2ee8f01ba2a0734af9514d369f3228
SpatialGate2d
import torch import torch.nn as nn class SpatialGate2d(nn.Module): def __init__(self, in_channels): super(SpatialGate2d, self).__init__() self.conv1 = nn.Conv2d(in_channels, 1, kernel_size=1, stride=1) self.sigmoid = nn.Sigmoid() def forward(self, x): cal = self.conv1(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 assert_size_stride = torch._C._dynamo.guards.assert_size_s...
bantiitnab/kaggle-TGS-salt-identification
SpatialGate2d
false
1,521
[ "MIT" ]
0
8b3350278b2ee8f01ba2a0734af9514d369f3228
https://github.com/bantiitnab/kaggle-TGS-salt-identification/tree/8b3350278b2ee8f01ba2a0734af9514d369f3228
HingeLoss
import torch class HingeLoss(torch.nn.Module): def __init__(self): super(HingeLoss, self).__init__() def forward(self, x, y, margin=2): output = (margin - x + y).clamp(min=0) return output.mean() def get_inputs(): return [torch.rand([4, 4, 4, 4]), torch.rand([4, 4, 4, 4])] de...
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 assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torc...
bashish101/ir
HingeLoss
false
1,522
[ "MIT" ]
0
cc90e86827c19035f38d0d85154f073a86aa9796
https://github.com/bashish101/ir/tree/cc90e86827c19035f38d0d85154f073a86aa9796
Critic
import torch import torch.nn as nn import torch.nn.functional as F class Critic(nn.Module): def __init__(self, state_size, action_size, action_parameter_size, hidden_layers=None, action_input_layer=0, init_type='normal', activation='leaky_relu', init_std=0.01): super(Critic, self).__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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
bcahlit/MP-DQN
Critic
false
1,523
[ "MIT" ]
0
d80d34680e20192134f39e5b7c43abbc6bff3ba1
https://github.com/bcahlit/MP-DQN/tree/d80d34680e20192134f39e5b7c43abbc6bff3ba1
Actor
import torch import numpy as np import torch.nn.functional as F import torch.nn as nn def hidden_init(layer): """ compute the bounds [-lim, lim] for subsequent uniform sampling with lim = 1/sqrt(nb_output) """ fan_in = layer.weight.data.size()[0] lim = 1.0 / np.sqrt(fan_in) return -lim, li...
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....
bar0net/Udacity_DeepReinforcementLearning
Actor
false
1,524
[ "MIT" ]
0
3b5f98b7c2c1911b351be541fda3aa190bf48456
https://github.com/bar0net/Udacity_DeepReinforcementLearning/tree/3b5f98b7c2c1911b351be541fda3aa190bf48456
BertOutput
from _paritybench_helpers import _mock_config import torch import torch.nn import torch.nn as nn class BertOutput(nn.Module): """BERT output layer. Based on: BERT (pytorch-transformer) https://github.com/huggingface/transformers """ def __init__(self, config) ->None: super().__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 imp...
bamf-health/MONAI
BertOutput
false
1,525
[ "Apache-2.0" ]
0
6a2086d21baf4b60c2ab3d400ed5c97cf24a0da9
https://github.com/bamf-health/MONAI/tree/6a2086d21baf4b60c2ab3d400ed5c97cf24a0da9
Actor
import torch import torch.nn as nn import torch.nn.functional as F class Actor(nn.Module): def __init__(self, state_size, action_size, action_parameter_size, hidden_layers=None, init_std=0.01, init_type='normal', activation= 'leaky_relu', squashing_function=False): super(Actor, self).__in...
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...
bcahlit/MP-DQN
Actor
false
1,526
[ "MIT" ]
0
d80d34680e20192134f39e5b7c43abbc6bff3ba1
https://github.com/bcahlit/MP-DQN/tree/d80d34680e20192134f39e5b7c43abbc6bff3ba1
BigRamDuel
import torch import torch.nn as nn from torch.nn import functional as F class BigRamDuel(nn.Module): """ Definition: DuelDQNet(obs_size, act_size) """ def __init__(self, obs_size, act_size): super().__init__() self.base = nn.Linear(obs_size, 256) self.fc1 = nn.Linear(256, 256)...
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_...
ayjabri/DeepRL
BigRamDuel
false
1,527
[ "MIT" ]
0
0be095e3a3d04f60b4cdc97ed330dffc17b3024a
https://github.com/ayjabri/DeepRL/tree/0be095e3a3d04f60b4cdc97ed330dffc17b3024a
duelingDQNnetwork
import torch import torch.nn.functional as F import torch.nn as nn class duelingDQNnetwork(nn.Module): """Actor (Policy) Model.""" def __init__(self, state_size, action_size, seed, fc1_units=64, fc2_units=64): """Initialize parameters and build model. Params ====== ...
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_...
beibeiJ/deep-reinforcement-learning
duelingDQNnetwork
false
1,528
[ "MIT" ]
0
ab1b0f4ada8da69af2e38d3e2e82e3ae55837c60
https://github.com/beibeiJ/deep-reinforcement-learning/tree/ab1b0f4ada8da69af2e38d3e2e82e3ae55837c60
LocAndConf
import torch import torch.nn as nn from math import sqrt as sqrt from itertools import product as product class LocAndConf(nn.Module): def __init__(self, c_in, c_out, num_classes): super(LocAndConf, self).__init__() self.c_in = c_in self.c_out = c_out self.num_classes = num_classe...
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 math import sqrt as sqrt from itertools import produc...
beichen2012/ssd.pytorch
LocAndConf
false
1,529
[ "MIT" ]
0
90b68a6903d2bef4c358e295d88b25e6fc6daf54
https://github.com/beichen2012/ssd.pytorch/tree/90b68a6903d2bef4c358e295d88b25e6fc6daf54
Actor
import torch import torch.nn as nn import torch.nn.functional as F class Actor(nn.Module): def __init__(self, state_dim, action_dim, max_action): super(Actor, self).__init__() self.l1 = nn.Linear(state_dim, 256) self.l2 = nn.Linear(256, 256) self.l3 = nn.Linear(256, action_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....
baturaysaglam/DISCOVER
Actor
false
1,530
[ "MIT" ]
0
423158c84a5935ca5755ccad06ea5fe20fb57d76
https://github.com/baturaysaglam/DISCOVER/tree/423158c84a5935ca5755ccad06ea5fe20fb57d76
PositionEncoder
from _paritybench_helpers import _mock_config import torch import numpy as np import torch.nn as nn class PositionEncoder(nn.Module): """ Encodes the information into vectors There are 2 pieces of information that goes into the encoded information: 1. Word Embedding 2. Position Embedding Thi...
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.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dyna...
benedictleedm/sgnlp
PositionEncoder
false
1,531
[ "MIT" ]
0
03f0fda8c517d9ca4baf737ce4c46b2495bbd3ba
https://github.com/benedictleedm/sgnlp/tree/03f0fda8c517d9ca4baf737ce4c46b2495bbd3ba
GeM
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn import Parameter from torch.nn.parameter import Parameter def gem(x, p=3, eps=1e-06): return F.avg_pool2d(x.clamp(min=eps).pow(p), (x.size(-2), x.size(-1))).pow( 1.0 / p) class GeM(nn.Module): def __init__(self, p=3.0,...
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 import...
beesk135/ReID-Survey
GeM
false
1,532
[ "MIT" ]
0
d1467c0ce5d3ca78640196360a05df9ff9f9f42a
https://github.com/beesk135/ReID-Survey/tree/d1467c0ce5d3ca78640196360a05df9ff9f9f42a
CoreNetwork
import torch import torch.nn as nn import torch.nn.functional as F class CoreNetwork(nn.Module): """The core network. An RNN that maintains an internal state by integrating information extracted from the history of past observations. It encodes the agent's knowledge of the environment through a 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._inductor.runtime import triton_helpers import torch.nn as nn assert_...
bennzo/DT-RAM-PyTorch
CoreNetwork
false
1,533
[ "MIT" ]
0
b364662ab7650ffd26cf129673752521e004b13a
https://github.com/bennzo/DT-RAM-PyTorch/tree/b364662ab7650ffd26cf129673752521e004b13a
MultiHeadAttention
import torch import torch.utils.data from torch import nn import torch.nn.functional as F class MultiHeadAttention(nn.Module): """ input: query --- [N, T_q, query_dim] key --- [N, T_k, key_dim] output: out --- [N, T_q, num_units] """ def __init__(self, query_dim, key_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....
azahed98/mellotron
MultiHeadAttention
false
1,534
[ "BSD-3-Clause" ]
0
02998743de820e379e0c7ff44506088d6e65c693
https://github.com/azahed98/mellotron/tree/02998743de820e379e0c7ff44506088d6e65c693
StoppingNetwork
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Bernoulli class StoppingNetwork(nn.Module): """The stopping network. Uses the internal state `h_t` of the core network to determine whether the network integrated enough information to make a confident ...
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 impo...
bennzo/DT-RAM-PyTorch
StoppingNetwork
false
1,535
[ "MIT" ]
0
b364662ab7650ffd26cf129673752521e004b13a
https://github.com/bennzo/DT-RAM-PyTorch/tree/b364662ab7650ffd26cf129673752521e004b13a
SACActorNetwork
import torch import torch.nn.functional as F import torch.nn as nn class SACActorNetwork(nn.Module): def __init__(self, input_shape, output_shape, n_features, **kwargs): super(SACActorNetwork, self).__init__() n_input = input_shape[-1] n_output = output_shape[0] self._h1 = nn.Line...
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_...
benvoe/mushroom-rl-benchmark
SACActorNetwork
false
1,536
[ "MIT" ]
0
217d8c077bf6f3febaed92821a2cf183c83f703b
https://github.com/benvoe/mushroom-rl-benchmark/tree/217d8c077bf6f3febaed92821a2cf183c83f703b
FeedForwardNetwork
from _paritybench_helpers import _mock_config import torch import torch.nn as nn class FeedForwardNetwork(nn.Module): """ Based on the paper, each layer has 2 subayers: A multi-headed attention mechanism & a position-wise fully connected feed-forward network Each layer employs a r...
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....
benedictleedm/sgnlp
FeedForwardNetwork
false
1,537
[ "MIT" ]
0
03f0fda8c517d9ca4baf737ce4c46b2495bbd3ba
https://github.com/benedictleedm/sgnlp/tree/03f0fda8c517d9ca4baf737ce4c46b2495bbd3ba
MLP
import torch class MLP(torch.nn.Module): def __init__(self, insize, outsize=128, nonlinear=torch.nn.ReLU, activation=torch.nn.ReLU, hidden_layer_size=1, node_size=256): super(MLP, self).__init__() self.net = torch.nn.Sequential() self.net.add_module('fc_1', torch.nn.Linear(insize,...
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 assert_size_stride = torch._C...
bengisug/multiagent-particle-envs
MLP
false
1,538
[ "MIT" ]
0
c87280f18fbaf885932fe6da4d600ab474fd83fe
https://github.com/bengisug/multiagent-particle-envs/tree/c87280f18fbaf885932fe6da4d600ab474fd83fe
Classification
import torch import torch.nn as nn import torch.nn.functional as F class Classification(torch.nn.Module): def __init__(self, num_class, hidden_dim): super(Classification, self).__init__() self.num_class = num_class self.label = nn.Linear(hidden_dim, num_class) def forward(self, input...
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....
bentherien/measevalcompetition
Classification
false
1,539
[ "MIT" ]
0
1d285991eb26403682a633a728629a9900923d80
https://github.com/bentherien/measevalcompetition/tree/1d285991eb26403682a633a728629a9900923d80
LocationNetwork
import torch import torch.nn as nn import torch.nn.functional as F from torch.distributions import Normal class LocationNetwork(nn.Module): """The location network. Uses the internal state `h_t` of the core network to produce the location coordinates `l_t` for the next time step. Concretely, fee...
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....
bennzo/DT-RAM-PyTorch
LocationNetwork
false
1,540
[ "MIT" ]
0
b364662ab7650ffd26cf129673752521e004b13a
https://github.com/bennzo/DT-RAM-PyTorch/tree/b364662ab7650ffd26cf129673752521e004b13a
A2CNetwork
import torch import torch.nn as nn class A2CNetwork(nn.Module): def __init__(self, input_shape, output_shape, n_features, **kwargs): super(A2CNetwork, self).__init__() n_input = input_shape[-1] n_output = output_shape[0] self._h1 = nn.Linear(n_input, n_features) self._h2 =...
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 ...
benvoe/mushroom-rl-benchmark
A2CNetwork
false
1,541
[ "MIT" ]
0
217d8c077bf6f3febaed92821a2cf183c83f703b
https://github.com/benvoe/mushroom-rl-benchmark/tree/217d8c077bf6f3febaed92821a2cf183c83f703b
BertMixedLayer
from _paritybench_helpers import _mock_config import math import torch import torch.nn import torch.nn as nn class BertAttention(nn.Module): """BERT attention layer. Based on: BERT (pytorch-transformer) https://github.com/huggingface/transformers """ def __init__(self, config) ->None: sup...
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....
bamf-health/MONAI
BertMixedLayer
false
1,542
[ "Apache-2.0" ]
0
6a2086d21baf4b60c2ab3d400ed5c97cf24a0da9
https://github.com/bamf-health/MONAI/tree/6a2086d21baf4b60c2ab3d400ed5c97cf24a0da9
SACCriticNetwork
import torch import torch.nn.functional as F import torch.nn as nn class SACCriticNetwork(nn.Module): def __init__(self, input_shape, output_shape, n_features, **kwargs): super().__init__() n_input = input_shape[-1] n_output = output_shape[0] self._h1 = nn.Linear(n_input, n_featur...
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_...
benvoe/mushroom-rl-benchmark
SACCriticNetwork
false
1,543
[ "MIT" ]
0
217d8c077bf6f3febaed92821a2cf183c83f703b
https://github.com/benvoe/mushroom-rl-benchmark/tree/217d8c077bf6f3febaed92821a2cf183c83f703b
Time2Vec
import torch from torch import nn class Time2Vec(nn.Module): def __init__(self, input_dim=4, embed_dim=248, act_function=torch.sin): assert embed_dim % input_dim == 0 super(Time2Vec, self).__init__() self.enabled = embed_dim > 0 if self.enabled: self.embed_dim = embed_...
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...
bernhein/spacetimeformer
Time2Vec
false
1,544
[ "MIT" ]
0
de252b68085943d979606fe69e177ac2a14586e7
https://github.com/bernhein/spacetimeformer/tree/de252b68085943d979606fe69e177ac2a14586e7
HardSwish
import torch import torch.nn as nn class HardSwish(nn.Module): def __init__(self): super().__init__() self.relu6 = nn.ReLU6() def forward(self, x): return self.relu6(x + 3.0) / 6.0 * 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._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
binyao2020/ElegantRL
HardSwish
false
1,545
[ "Apache-2.0" ]
0
bf79f0d071d00cd93be03f1ca005020c3ab8dfe0
https://github.com/binyao2020/ElegantRL/tree/bf79f0d071d00cd93be03f1ca005020c3ab8dfe0
RMSELoss
import torch import torch as th import torch.nn as nn class RMSELoss(nn.Module): def __init__(self, reduction='mean', eps=1e-06): super().__init__() self.mse = nn.MSELoss(reduction=reduction) self.eps = eps def forward(self, yhat, y): loss = th.sqrt(self.mse(yhat, y) + self.e...
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...
bio-ontology-research-group/OntoML
RMSELoss
false
1,546
[ "BSD-3-Clause" ]
0
4cdc17dc7ee26464db96c67838c3e77dba5318f9
https://github.com/bio-ontology-research-group/OntoML/tree/4cdc17dc7ee26464db96c67838c3e77dba5318f9
GumbelQuantize
import torch from torch import nn from torch import einsum import torch.nn.functional as F class GumbelQuantize(nn.Module): """ Gumbel Softmax trick quantizer Categorical Reparameterization with Gumbel-Softmax, Jang et al. 2016 https://arxiv.org/abs/1611.01144 """ def __init__(self, num_hidde...
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....
baudm/deep-vector-quantization
GumbelQuantize
false
1,547
[ "MIT" ]
0
211bda99a6c750c1e65aff082aa865fed8677b8a
https://github.com/baudm/deep-vector-quantization/tree/211bda99a6c750c1e65aff082aa865fed8677b8a
TwoMLPHead
import torch import torch.utils.data from torch import nn from torchvision.transforms import functional as F import torch.nn.functional as F class TwoMLPHead(nn.Module): """ Heads for FPN for classification """ def __init__(self, in_channels, representation_size): super(TwoMLPHead, self).__in...
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 from ...
billchenxi/vision
TwoMLPHead
false
1,548
[ "BSD-3-Clause" ]
0
5608b06a6fbc9c84284dad9f07a16df61da10f85
https://github.com/billchenxi/vision/tree/5608b06a6fbc9c84284dad9f07a16df61da10f85
QNetwork
import torch import torch.nn.functional as F import torch.nn as nn class QNetwork(nn.Module): """Actor (Policy) Model.""" def __init__(self, state_size, action_size, seed): """Initialize parameters and build model. Params ====== state_size (int): Dimension of each state ...
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_...
bhattsachin/deep-reinforcement-learning
QNetwork
false
1,549
[ "MIT" ]
0
4d75b012495009bf156273e170d75caf400fa7aa
https://github.com/bhattsachin/deep-reinforcement-learning/tree/4d75b012495009bf156273e170d75caf400fa7aa
GlobalpoolFC
import torch from torch import nn class GlobalpoolFC(nn.Module): def __init__(self, num_in, num_class): super(GlobalpoolFC, self).__init__() self.pool = nn.AdaptiveAvgPool2d(output_size=1) self.fc = nn.Linear(num_in, num_class) def forward(self, x): rep = self.pool(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 from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_st...
blackcow/Fair-AT
GlobalpoolFC
false
1,550
[ "Apache-2.0" ]
0
62fc269fedd4b63c4b48ae390d494b3832e65fa8
https://github.com/blackcow/Fair-AT/tree/62fc269fedd4b63c4b48ae390d494b3832e65fa8
FairLoss
import torch from torch import nn class FairLoss(nn.Module): def __init__(self, lamda): super(FairLoss, self).__init__() self.lamda = lamda def forward(self, rep): logits = torch.mm(rep, torch.transpose(rep, 0, 1)) logits = logits - torch.diag_embed(torch.diag(logits)) ...
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...
blackcow/Fair-AT
FairLoss
false
1,551
[ "Apache-2.0" ]
0
62fc269fedd4b63c4b48ae390d494b3832e65fa8
https://github.com/blackcow/Fair-AT/tree/62fc269fedd4b63c4b48ae390d494b3832e65fa8
MockOpposite
import torch import torch.nn as nn class MockOpposite(nn.Module): def __init__(self): """Initialize the model""" super(MockOpposite, self).__init__() def forward(self, input): """A single forward pass of the model. Returns input - 1. Args: input: The input to the...
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...
blagojce95/ai-research-mamo-framework
MockOpposite
false
1,552
[ "Apache-2.0" ]
0
7f3b5a5a9fb8b19c9eef453b81b03b6046a33bf2
https://github.com/blagojce95/ai-research-mamo-framework/tree/7f3b5a5a9fb8b19c9eef453b81b03b6046a33bf2
PatchMerging
import torch import torch.nn as nn import torch.nn.functional as F from math import sqrt from torch import optim as optim class PatchMerging(nn.Module): """Patch Merging Layer. Args: input_resolution (tuple[int]): Resolution of input feature. dim (int): Number of input channels. norm_...
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 ...
billpsomas/ibot
PatchMerging
false
1,553
[ "Apache-2.0" ]
0
c6fbce7e2a59780f39ad7304ed9a8b1acf038d2d
https://github.com/billpsomas/ibot/tree/c6fbce7e2a59780f39ad7304ed9a8b1acf038d2d
MyModel
import torch import torch.nn as nn class MyModel(nn.Module): def __init__(self): super(MyModel, self).__init__() def forward(self, x): return x + 1 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
blagojce95/ai-research-mamo-framework
MyModel
false
1,554
[ "Apache-2.0" ]
0
7f3b5a5a9fb8b19c9eef453b81b03b6046a33bf2
https://github.com/blagojce95/ai-research-mamo-framework/tree/7f3b5a5a9fb8b19c9eef453b81b03b6046a33bf2
GreedyTop1
import torch from typing import Optional import torch as pt import torch.distributed import torch.distributed.elastic.multiprocessing.errors class GreedyTop1(pt.nn.Module): """ Implements picking the highest scoring next word with support for vocabulary selection and target factors. """ def forward(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 import torch as pt import torch.distributed import torch.distributed.elastic.multiprocessing.errors assert_size_stride = torch._C._dynamo.gu...
blchu/sockeye
GreedyTop1
false
1,555
[ "Apache-2.0" ]
0
28044a44ee409c9b3df1711c0b16bdebdd463b2e
https://github.com/blchu/sockeye/tree/28044a44ee409c9b3df1711c0b16bdebdd463b2e
PyTorchLHUC
import torch import torch as pt import torch.distributed import torch.distributed.elastic.multiprocessing.errors class PyTorchLHUC(pt.nn.Module): """ Learning Hidden Unit Contribution David Vilar. "Learning Hidden Unit Contribution for Adapting Neural Machine Translation Models" NAACL 2018 :para...
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 as pt import torch.distributed import torch.distributed.elastic.multiprocessing.errors assert_size_stride = torch._C._dynamo.gu...
blchu/sockeye
PyTorchLHUC
false
1,556
[ "Apache-2.0" ]
0
28044a44ee409c9b3df1711c0b16bdebdd463b2e
https://github.com/blchu/sockeye/tree/28044a44ee409c9b3df1711c0b16bdebdd463b2e
SE
import torch from itertools import chain as chain import torch.utils.data import torch.nn as nn class SwishEfficient(torch.autograd.Function): """Swish activation function: x * sigmoid(x).""" @staticmethod def forward(ctx, x): result = x * torch.sigmoid(x) ctx.save_for_backward(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 from torch._inductor.runtime import triton_helpers from itertools import chain a...
billcai/SlowFast
SE
false
1,557
[ "Apache-2.0" ]
0
778888e63351e55861801996b37c7ff9a3746587
https://github.com/billcai/SlowFast/tree/778888e63351e55861801996b37c7ff9a3746587
SimpleNormLayer
import torch import torch.nn as nn class SimpleNormLayer(nn.Module): """Simple normalization layer that divides the output of a preceding layer by a specified number Parameters ---------- normalization_strength: float The number with which input is normalized/dived by """ def __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 torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
bokutotu/cgnet
SimpleNormLayer
false
1,558
[ "BSD-3-Clause" ]
0
a35170001d969d51548dd01522b1ab93e43741b4
https://github.com/bokutotu/cgnet/tree/a35170001d969d51548dd01522b1ab93e43741b4
Net
import torch import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def __init__(self, feature_num): super(Net, self).__init__() self.layer_1 = nn.Linear(feature_num, 500) self.layer_2 = nn.Linear(500, 20) def forward(self, x): x = F.relu(self.layer_1(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 from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_...
bm2-lab/MDML
Net
false
1,559
[ "MIT" ]
0
222fb22b2ee53dd3c1a6f2e99a88f71e9635e3a0
https://github.com/bm2-lab/MDML/tree/222fb22b2ee53dd3c1a6f2e99a88f71e9635e3a0
PyTorchSSRU
import torch from typing import Tuple from abc import abstractmethod import torch as pt import torch.distributed import torch.distributed.elastic.multiprocessing.errors class AutoregressiveLayer(pt.nn.Module): @property @abstractmethod def num_state_tensors(self) ->int: """ Number of state tensor...
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 typing import Tuple from...
blchu/sockeye
PyTorchSSRU
false
1,560
[ "Apache-2.0" ]
0
28044a44ee409c9b3df1711c0b16bdebdd463b2e
https://github.com/blchu/sockeye/tree/28044a44ee409c9b3df1711c0b16bdebdd463b2e
ShiftedSoftplus
import torch import numpy as np import torch.nn as nn class ShiftedSoftplus(nn.Module): """ Shifted softplus (SSP) activation function SSP originates from the softplus function: y = \\ln\\left(1 + e^{-x}\\right) Schütt et al. (2018) introduced a shifting factor to the function in order to e...
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, math as tl_math import torch.nn as nn assert_size_stride = torch._C._dynamo.gu...
bokutotu/cgnet
ShiftedSoftplus
false
1,561
[ "BSD-3-Clause" ]
0
a35170001d969d51548dd01522b1ab93e43741b4
https://github.com/bokutotu/cgnet/tree/a35170001d969d51548dd01522b1ab93e43741b4
PatchEmbed
import torch from itertools import chain as chain import torch.utils.data import torch.nn as nn class PatchEmbed(nn.Module): """ PatchEmbed. """ def __init__(self, dim_in=3, dim_out=768, kernel=(1, 16, 16), stride=(1, 4, 4), padding=(1, 7, 7), conv_2d=False): super().__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 itertools import chain as chain import torch.utils.data import torch.nn as ...
billcai/SlowFast
PatchEmbed
false
1,562
[ "Apache-2.0" ]
0
778888e63351e55861801996b37c7ff9a3746587
https://github.com/billcai/SlowFast/tree/778888e63351e55861801996b37c7ff9a3746587
NeighborNormLayer
import torch import torch.nn as nn class NeighborNormLayer(nn.Module): """Normalization layer that divides the output of a preceding layer by the number of neighbor features. Unlike the SimpleNormLayer, this layer allows for dynamically changing number of neighbors during training. """ 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
bokutotu/cgnet
NeighborNormLayer
false
1,563
[ "BSD-3-Clause" ]
0
a35170001d969d51548dd01522b1ab93e43741b4
https://github.com/bokutotu/cgnet/tree/a35170001d969d51548dd01522b1ab93e43741b4
MultiheadSimilarity
import torch import torch.utils.data from torch import nn class MultiheadSimilarity(nn.Module): def __init__(self, d_model, num_head, seq_len, in_proj=True): super().__init__() self.num_head = num_head self.seq_len = seq_len self.d_head = d_model // num_head self.in_proj =...
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.utils.data from torch import nn assert_size_stride = torch._C._dyna...
bladewaltz1/clipvid-tmp
MultiheadSimilarity
false
1,564
[ "MIT" ]
0
8a4a990c318fdfbf6dac443abd3bc16637abba3d
https://github.com/bladewaltz1/clipvid-tmp/tree/8a4a990c318fdfbf6dac443abd3bc16637abba3d
ResidualBlock
import torch from torch import nn class ResidualBlock(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() self.in_channels, self.out_channels = in_channels, out_channels self.blocks = nn.Identity() self.shortcut = nn.Identity() self.should_apply_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 import nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride @triton.jit def triton_poi_fused_add_0(in_ptr0, out_p...
boxiXia/pytorch_sac
ResidualBlock
false
1,565
[ "MIT" ]
0
ad570845c482498769217b398c22fafaff2ff2f1
https://github.com/boxiXia/pytorch_sac/tree/ad570845c482498769217b398c22fafaff2ff2f1
ChannelAttention
import torch import torch.nn as nn class ChannelAttention(nn.Module): def __init__(self, in_planes=96, ratio=16): super(ChannelAttention, self).__init__() self.avg_pool = nn.AdaptiveAvgPool2d(1) self.max_pool = nn.AdaptiveMaxPool2d(1) self.fc1 = nn.Conv2d(in_planes, in_planes // r...
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_...
biolee3/SAMDNet
ChannelAttention
false
1,566
[ "MIT" ]
0
9a0d70f976e22d512046b4aa5727dd26422d0aff
https://github.com/biolee3/SAMDNet/tree/9a0d70f976e22d512046b4aa5727dd26422d0aff
MiniBatchStddevLayer
import torch import torch.nn as nn import torch.distributed as dist import torch.autograd as autograd import torch.utils.cpp_extension class AllGatherLayer(autograd.Function): """All gather layer with backward propagation path. Indeed, this module is to make ``dist.all_gather()`` in the backward graph. 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.triton_helpers import libdevice import torch.nn as nn import torch.distributed as dist import torch.autograd as...
bladesaber/mmgeneration
MiniBatchStddevLayer
false
1,567
[ "Apache-2.0" ]
0
158b49f7efd8028f231f6e9ca758ae0e20dd72ae
https://github.com/bladesaber/mmgeneration/tree/158b49f7efd8028f231f6e9ca758ae0e20dd72ae
SigmoidFocalLoss
import torch import torch.nn as nn from torch.nn import functional as F def sigmoid_focal_loss(inputs: 'torch.Tensor', targets: 'torch.Tensor', alpha: 'float'=-1, gamma: 'float'=2, reduction: 'str'='none' ) ->torch.Tensor: """ Loss used in RetinaNet for dense detection: https://arxiv.org/abs/1708.0200...
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...
botkop/lark
SigmoidFocalLoss
false
1,568
[ "Apache-2.0" ]
0
edb2defdb514213fc121418578b0d9006a55f3a0
https://github.com/botkop/lark/tree/edb2defdb514213fc121418578b0d9006a55f3a0
LSTM
import torch import torch.nn as nn class LSTM(nn.Module): def __init__(self, seq_length, input_dim, num_hidden, num_classes, batch_size, device='cpu'): super(LSTM, self).__init__() self.seq_length = seq_length self.h_init = nn.Parameter(torch.zeros(num_hidden, 1), requ...
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 ...
askliar/deep_learning
LSTM
false
1,569
[ "MIT" ]
0
e61b2391a3258d18719bf12d9ed1404620ce6c02
https://github.com/askliar/deep_learning/tree/e61b2391a3258d18719bf12d9ed1404620ce6c02
PatchEmbed
import torch import torch.nn as nn from torch import optim as optim class PatchEmbed(nn.Module): """ Image to Patch Embedding """ def __init__(self, img_size=224, patch_size=16, in_chans=3, embed_dim=768): super().__init__() num_patches = img_size // patch_size * (img_size // patch_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 import torch.nn as nn from torch import optim as optim assert_size_stride = torc...
billpsomas/ibot
PatchEmbed
false
1,570
[ "Apache-2.0" ]
0
c6fbce7e2a59780f39ad7304ed9a8b1acf038d2d
https://github.com/billpsomas/ibot/tree/c6fbce7e2a59780f39ad7304ed9a8b1acf038d2d
FocalLoss
import torch import torch.nn as nn class FocalLoss(nn.Module): def __init__(self, alpha: 'float'=0.25, gamma: 'float'=2.0, reduction: 'str'='mean'): super().__init__() self.bce = nn.BCEWithLogitsLoss(reduction='none') self.alpha = alpha self.gamma = gamma if reduct...
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...
botkop/lark
FocalLoss
false
1,571
[ "Apache-2.0" ]
0
edb2defdb514213fc121418578b0d9006a55f3a0
https://github.com/botkop/lark/tree/edb2defdb514213fc121418578b0d9006a55f3a0
SReLU
import torch import torch.nn as nn class SReLU(nn.Module): """Shifted ReLU""" def __init__(self, nc): super(SReLU, self).__init__() self.srelu_bias = nn.Parameter(torch.Tensor(1, nc, 1, 1)) self.srelu_relu = nn.ReLU(inplace=True) nn.init.constant_(self.srelu_bias, -1.0) 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 from torch._inductor.runtime import triton_helpers import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride emp...
bpicnbnk/ISONet
SReLU
false
1,572
[ "MIT" ]
0
993150fa215dbc92460142ade59a3a5ec4a0efd9
https://github.com/bpicnbnk/ISONet/tree/993150fa215dbc92460142ade59a3a5ec4a0efd9
AdaptiveInstanceNorm
import torch import torch.nn as nn from torch.nn.init import _calculate_correct_fan import torch.utils.cpp_extension def equalized_lr(module, name='weight', gain=2 ** 0.5, mode='fan_in', lr_mul=1.0): """Equalized Learning Rate. This trick is proposed in: Progressive Growing of GANs for Improved Quali...
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 ...
bladesaber/mmgeneration
AdaptiveInstanceNorm
false
1,573
[ "Apache-2.0" ]
0
158b49f7efd8028f231f6e9ca758ae0e20dd72ae
https://github.com/bladesaber/mmgeneration/tree/158b49f7efd8028f231f6e9ca758ae0e20dd72ae
PANNsLoss
import torch import torch.nn as nn from torch.nn import functional as F class PANNsLoss(nn.Module): def __init__(self): super().__init__() @staticmethod def stabilize_input(cwo): cwo = torch.where(torch.isnan(cwo), torch.zeros_like(cwo), cwo) cwo = torch.where(torch.isinf(cwo), 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...
botkop/lark
PANNsLoss
false
1,574
[ "Apache-2.0" ]
0
edb2defdb514213fc121418578b0d9006a55f3a0
https://github.com/botkop/lark/tree/edb2defdb514213fc121418578b0d9006a55f3a0
SigmoidFocalLossStar
import torch import torch.nn as nn from torch.nn import functional as F def sigmoid_focal_loss_star(inputs: 'torch.Tensor', targets: 'torch.Tensor', alpha: 'float'=-1, gamma: 'float'=1, reduction: 'str'='none' ) ->torch.Tensor: """ FL* described in RetinaNet paper Appendix: https://arxiv.org/abs/1708....
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...
botkop/lark
SigmoidFocalLossStar
false
1,575
[ "Apache-2.0" ]
0
edb2defdb514213fc121418578b0d9006a55f3a0
https://github.com/botkop/lark/tree/edb2defdb514213fc121418578b0d9006a55f3a0
ModMBStddevLayer
import torch import torch.nn as nn import torch.distributed as dist import torch.autograd as autograd import torch.utils.cpp_extension class AllGatherLayer(autograd.Function): """All gather layer with backward propagation path. Indeed, this module is to make ``dist.all_gather()`` in the backward graph. 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.triton_helpers import libdevice import torch.nn as nn import torch.distributed as dist import torch.autograd as...
bladesaber/mmgeneration
ModMBStddevLayer
false
1,576
[ "Apache-2.0" ]
0
158b49f7efd8028f231f6e9ca758ae0e20dd72ae
https://github.com/bladesaber/mmgeneration/tree/158b49f7efd8028f231f6e9ca758ae0e20dd72ae
CriticArchitecture
import torch import numpy as np from abc import ABC import torch.nn.functional as F from torch import nn from torch.nn import init def fan_in_init(tensor): fan_in = tensor.size(1) v = 1.0 / np.sqrt(fan_in) init.uniform_(tensor, -v, v) class Architecture(nn.Module, ABC): 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 import triton_helpers import numpy as np from abc i...
bootml/agent
CriticArchitecture
false
1,577
[ "Apache-2.0" ]
0
84235db931d6e4ef956962961c619994898ebdd5
https://github.com/bootml/agent/tree/84235db931d6e4ef956962961c619994898ebdd5
SelfGating
import torch import torch.utils.data import torch as th import torch.nn as nn import torch.nn.parallel import torch.optim import torch.utils.data.distributed class SelfGating(nn.Module): def __init__(self, input_dim): super(SelfGating, self).__init__() self.fc = nn.Linear(input_dim, input_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 import torch.utils.data import torch.nn as nn import torch.nn.parallel import to...
bryant1410/MIL-NCE_HowTo100M
SelfGating
false
1,578
[ "Apache-2.0" ]
0
9ba876bd67160e24a5ce379a07d18a8036be0d36
https://github.com/bryant1410/MIL-NCE_HowTo100M/tree/9ba876bd67160e24a5ce379a07d18a8036be0d36
LearnedPositionalEmbedding
import torch import torch.nn as nn import torch.nn.functional as F class LearnedPositionalEmbedding(nn.Embedding): """ This module learns positional embeddings up to a fixed maximum size. Padding ids are ignored by either offsetting based on padding_idx or by setting padding_idx to None and ensuring 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 import torch.nn as nn assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torch._C._dynamo.guards._empty_st...
boxiangliu/esm
LearnedPositionalEmbedding
false
1,579
[ "MIT" ]
0
3c143d99103e0ea38a9455f30a73cd9c87376606
https://github.com/boxiangliu/esm/tree/3c143d99103e0ea38a9455f30a73cd9c87376606
simple_mlp
import torch import torch.nn as nn from torch.nn import functional as F class simple_mlp(nn.Module): def __init__(self, feature_dim, layer, hidden): super(simple_mlp, self).__init__() self.layer = layer self.linear1 = nn.Linear(feature_dim, hidden) if layer == 2: 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_...
broadinstitute/TCRP
simple_mlp
false
1,580
[ "MIT" ]
0
9e580dbf0c9d0ec5e5b1a949087df5a3724fa35b
https://github.com/broadinstitute/TCRP/tree/9e580dbf0c9d0ec5e5b1a949087df5a3724fa35b
MaskedInstanceNorm1d
import torch import torch.cuda from torch import nn import torch.distributed import torch.utils.data import torch.optim class MaskedInstanceNorm1d(nn.Module): """Instance norm + masking.""" MAX_CNT = 100000.0 def __init__(self, d_channel: 'int', unbiased: 'bool'=True, affine: 'bool'=False): ...
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.cuda from torch...
bugface/NeMo
MaskedInstanceNorm1d
false
1,581
[ "Apache-2.0" ]
0
431c561380a120e9e164a4c9deed8f1ca9acace5
https://github.com/bugface/NeMo/tree/431c561380a120e9e164a4c9deed8f1ca9acace5
LayerNorm
import torch from torch import nn class LayerNorm(nn.Module): def __init__(self, d_model, eps=1e-12): super(LayerNorm, self).__init__() self.gamma = nn.Parameter(torch.ones(d_model)) self.beta = nn.Parameter(torch.zeros(d_model)) self.eps = eps def forward(self, x): m...
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 from torch import nn assert_size_stride = torch._C._dynamo.guards.assert_size_s...
bsgiovanini/transformer
LayerNorm
false
1,582
[ "Apache-2.0" ]
0
e128fa862f1b3d17d7b92df169a2bbee3f08366f
https://github.com/bsgiovanini/transformer/tree/e128fa862f1b3d17d7b92df169a2bbee3f08366f
Actor
import torch import numpy as np import torch.nn as nn def fanin_init(size, fanin=None): fanin = fanin or size[0] v = 1.0 / np.sqrt(fanin) return torch.Tensor(size).uniform_(-v, v) class Actor(nn.Module): def __init__(self, s_dim, a_dim): super(Actor, self).__init__() self.forward1 =...
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....
brooky56/DeepRL-UR-motion-planning
Actor
false
1,583
[ "MIT" ]
0
0cc523da6d8a55896773f1f57feed1f0c77fea78
https://github.com/brooky56/DeepRL-UR-motion-planning/tree/0cc523da6d8a55896773f1f57feed1f0c77fea78
ScaleDotProductAttention
import math import torch from torch import nn class ScaleDotProductAttention(nn.Module): """ compute scale dot product attention Query : given sentence that we focused on (decoder) Key : every sentence to check relationship with Qeury(encoder) Value : every sentence same with Key (encoder) ""...
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....
bsgiovanini/transformer
ScaleDotProductAttention
false
1,584
[ "Apache-2.0" ]
0
e128fa862f1b3d17d7b92df169a2bbee3f08366f
https://github.com/bsgiovanini/transformer/tree/e128fa862f1b3d17d7b92df169a2bbee3f08366f
EqualLinearActModule
import torch import torch.nn as nn from copy import deepcopy from functools import partial from torch.nn.init import _calculate_correct_fan import torch.utils.cpp_extension def equalized_lr(module, name='weight', gain=2 ** 0.5, mode='fan_in', lr_mul=1.0): """Equalized Learning Rate. This trick is propose...
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 copy import deepcopy from functools import partial fr...
bladesaber/mmgeneration
EqualLinearActModule
false
1,585
[ "Apache-2.0" ]
0
158b49f7efd8028f231f6e9ca758ae0e20dd72ae
https://github.com/bladesaber/mmgeneration/tree/158b49f7efd8028f231f6e9ca758ae0e20dd72ae
NPairLoss
import torch class NPairLoss(torch.nn.Module): def __init__(self, l2=0.05): """ Basic N-Pair Loss as proposed in 'Improved Deep Metric Learning with Multi-class N-pair Loss Objective' Args: l2: float, weighting parameter for weight penality due to embeddings not being normaliz...
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 assert_size_s...
bm2-lab/MDML
NPairLoss
false
1,586
[ "MIT" ]
0
222fb22b2ee53dd3c1a6f2e99a88f71e9635e3a0
https://github.com/bm2-lab/MDML/tree/222fb22b2ee53dd3c1a6f2e99a88f71e9635e3a0
FunctionalRelu6
import torch class FunctionalRelu6(torch.nn.Module): def forward(self, x): return torch.nn.functional.relu6(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._inductor.runtime import triton_helpers assert_size_stride = torch._C._dynamo.guards.assert_size_stride empty_strided_cuda = torc...
bunderhi/torch2trt
FunctionalRelu6
false
1,587
[ "MIT" ]
0
fa5e31e742a0f0c9a9ee38909a6fa56bb07ba96d
https://github.com/bunderhi/torch2trt/tree/fa5e31e742a0f0c9a9ee38909a6fa56bb07ba96d