Kernel-Smith
Collection
4 items • Updated
uuid int64 18.5k 561k | python_code stringlengths 189 56.8k | repo_id stringlengths 12 32 | repo_name stringlengths 2 100 | repo_star_count int64 0 148k | entry_point stringlengths 1 81 | level int64 1 3 |
|---|---|---|---|---|---|---|
18,605 | import torch
from torch import nn
class RMSNorm(nn.Module):
def __init__(self, in_channels: int, elementwise_affine: bool=False, eps: float=1e-06):
super().__init__()
self.eps = eps
self.learnable_scale = elementwise_affine
if self.learnable_scale:
self.weight = nn.Para... | R_kgDONmLyPg | stable_diffusion_3.5-pytorch-implementation | 2 | RMSNorm | 2 |
18,802 | import torch
import torch.nn as nn
class MockNetwork(nn.Module):
def __init__(self):
super(MockNetwork, self).__init__()
self.p = nn.Parameter(torch.zeros(1))
def forward(self, x):
x = self.p * x
return x
def get_inputs():
return [torch.rand([4, 3])]
def get_init_inputs(... | R_kgDONltf4A | pytorch-model-template | 0 | MockNetwork | 1 |
18,576 | import torch
from torch.nn import Module
class TensorPerAtomRMSE(Module):
"""Define RMSE Loss following the work:
Wilkins, David M., et al. "Accurate molecular polarizabilities with coupled cluster theory and machine learning."
Proceedings of the National Academy of Sciences 116.9 (2019): 3401-3406.
""... | R_kgDONkj93Q | ENINet | 2 | TensorPerAtomRMSE | 3 |
19,016 | import sys
import torch
class ZeroPadding2D(torch.nn.Module):
def __init__(self, padding, **kwargs):
super().__init__()
padding = (padding[1][0], padding[1][1], padding[0][0], padding[0][1])
self.task = None
self.pad = torch.nn.ZeroPad2d(padding=padding)
def forward(self, x):
... | R_kgDONkjAlw | Rex | 0 | ZeroPadding2D | 1 |
18,956 | import torch
esp = 1e-08
class Fidelity_Loss(torch.nn.Module):
def __init__(self):
super(Fidelity_Loss, self).__init__()
def forward(self, p, g):
g = g.view(-1, 1)
p = p.view(-1, 1)
loss = 1 - (torch.sqrt(p * g + esp) + torch.sqrt((1 - p) * (1 - g) + esp))
return torc... | R_kgDONlaCPA | AIGFD_EXIF | 3 | Fidelity_Loss | 3 |
18,893 | import torch
from torch import nn
class DivXActivation(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
try:
return 1 / x
except ZeroDivisionError:
return 0
def get_inputs():
return [torch.rand([4, 3, 4, 4])]
def get_init_inputs():... | R_kgDONlNDcw | learning-pytorch-from-daniel-bourke | 0 | DivXActivation | 1 |
19,131 | import torch
from torch import nn
class PACTReLU(nn.ReLU):
def __init__(self, alpha=1.0, inplace=False):
super().__init__(inplace)
self.alpha = torch.nn.Parameter(torch.tensor(alpha), requires_grad=True)
def forward(self, x):
return torch.clamp(x, torch.tensor(0).to(x.device), self.al... | R_kgDONlZvSg | compress | 0 | PACTReLU | 2 |
19,091 | import torch
import torch.nn as nn
import torch.nn.functional as F
class DisparitySmoothnessLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, disparites, images, separate=False):
image_gradient_x = self.gradient_x(images)
image_gradient_y = self.gradient_y(imag... | R_kgDONnWRwg | monodepth | 1 | DisparitySmoothnessLoss | 3 |
19,069 | import torch
from torch import nn
class ReadOut(nn.Module):
def __init__(self):
super().__init__()
self.sigm = nn.Sigmoid()
def forward(self, V):
out = torch.mean(V, 1)
return self.sigm(out)
def get_inputs():
return [torch.rand([4, 10, 8])]
def get_init_inputs():
ret... | R_kgDONlOr8A | graph-representation-learning | 0 | ReadOut | 1 |
18,577 | import torch
from torch import Tensor
class BesselRBF(torch.nn.Module):
"""
Sine for radial basis functions with coulomb decay (0th order bessel).
"""
def __init__(self, n_rbf: int, cutoff: float):
"""
Args:
cutoff: radial cutoff
n_rbf: number of basis functions... | R_kgDONkj93Q | ENINet | 2 | BesselRBF | 2 |
19,019 | import torch
class DepthwiseConv2D(torch.nn.Module):
def __init__(self, in_channels, kernel_size, strides=(1, 1), padding='same', use_bias=True, activation=None, dilation_rate=(1, 1), stride_offset=1, **kwargs):
super().__init__()
if padding == 'same' and strides in [2, (2, 2)]:
paddin... | R_kgDONkjAlw | Rex | 0 | DepthwiseConv2D | 1 |
18,925 | import torch
import torch.nn as nn
class CrossEntropyWrapper(nn.Module):
def __init__(self, weight, size_average):
super(CrossEntropyWrapper, self).__init__()
self.cross_entropy = nn.CrossEntropyLoss(weight=weight, size_average=size_average)
def forward(self, output, target):
x = outp... | R_kgDONm36GQ | PipeOptim | 0 | CrossEntropyWrapper | 2 |
18,611 | import torch
import math
import torch.nn as nn
class DWConvNormAct(nn.Module):
def __init__(self, d_model, k_size, dim):
super().__init__()
self.dim = dim
if dim == 2:
self.conv = nn.Conv2d(d_model, d_model, k_size, padding=k_size // 2, groups=d_model, bias=False)
elif ... | R_kgDONnXo3w | VLM-LwEIB | 10 | DWConvNormAct | 3 |
18,604 | import torch
from torch import nn
class SimplifiedLayerNorm(nn.Module):
def __init__(self, in_channels: int, eps=1e-06):
super().__init__()
self.weight = nn.Parameter(torch.ones(in_channels))
self.eps = eps
def forward(self, x: torch.Tensor) -> torch.Tensor:
var = x.pow(2).mea... | R_kgDONmLyPg | stable_diffusion_3.5-pytorch-implementation | 2 | SimplifiedLayerNorm | 2 |
18,899 | import torch
from torch import nn
class ModulusX(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return torch.abs(x)
def get_inputs():
return [torch.rand([4, 3, 224, 224])]
def get_init_inputs():
return [[], {}] | R_kgDONlNDcw | learning-pytorch-from-daniel-bourke | 0 | ModulusX | 1 |
18,839 | import torch
import torch.nn as nn
import torch.nn.functional as F
class CLSTaskHead(nn.Module):
def __init__(self):
super().__init__()
self.fc = nn.Sequential(nn.Linear(50, 50), nn.ReLU(), nn.Linear(50, 10))
def forward(self, x):
assert (x != 0).sum() != 0
return F.log_softma... | R_kgDONm2Yew | EMTAL | 9 | CLSTaskHead | 2 |
18,871 | import torch
import torch.nn as nn
class BiLSTM(nn.Module):
def __init__(self, in_dim, out_dim):
super(BiLSTM, self).__init__()
self.layernorm = nn.LayerNorm(in_dim)
self.bilstm = nn.LSTM(in_dim, out_dim, batch_first=True, bidirectional=True, bias=False)
def forward(self, x):
... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | BiLSTM | 2 |
18,514 | import torch
from torch import Tensor, nn
class Downsample(nn.Module):
"""
下采样模块,用于在神经网络中降低特征图的空间分辨率。
该模块通过步幅为 2 的卷积层实现下采样,同时保持通道数不变。
参数:
in_channels (int): 输入特征的通道数。
"""
def __init__(self, in_channels: int):
super().__init__()
self.conv = nn.Conv2d(in_channels, in_ch... | R_kgDONnbfBg | FLUX-PyTorch | 3 | Downsample | 1 |
18,896 | import torch
from torch import nn
class BlobModel(nn.Module):
def __init__(self, input_size: int, output_size: int, hidden_layer_volume: int):
super().__init__()
self.input_size = input_size
self.output_size = output_size
self.hidden_layer_volume = hidden_layer_volume
self.... | R_kgDONlNDcw | learning-pytorch-from-daniel-bourke | 0 | BlobModel | 3 |
18,804 | import torch
import torch.nn as nn
class FNNGenerator(nn.Module):
"""
A customizable feedforward neural network generator.
"""
def __init__(self, input_size, output_size, hidden_layers, hidden_activations=None):
"""
Initializes the feedforward neural network.
Args:
... | R_kgDONlsjYA | PyTorch-wrapper | 0 | FNNGenerator | 1 |
18,597 | import torch
from torch import nn
from torch.nn import functional as F
class DenseGeluDense(nn.Module):
def __init__(self, in_channels: int, hidden_dim: int):
super().__init__()
self.wi_0 = nn.Linear(in_channels, hidden_dim, bias=False)
self.wi_1 = nn.Linear(in_channels, hidden_dim, bias=F... | R_kgDONmLyPg | stable_diffusion_3.5-pytorch-implementation | 2 | DenseGeluDense | 2 |
18,811 | import torch
from torch import nn
class TextTransformer(nn.Module):
def __init__(self, embed_dim, n_heads, n_layers, mlp_ratio, vocab_size, dropout, device):
super().__init__()
self.token_embedding = nn.Embedding(vocab_size, embed_dim)
self.positional_embedding = nn.Parameter(torch.zeros(1... | R_kgDONlQYzA | PyTorch-CLIP | 0 | TextTransformer | 3 |
18,719 | import torch
import torch.nn as nn
import torch.nn.init as init
class Maxout(nn.Module):
def __init__(self, in_features, out_features, num_pieces=5, bias=True):
super(Maxout, self).__init__()
assert in_features == out_features, 'For identity-like behavior, in_features must equal out_features.'
... | R_kgDONm_Q6Q | maxout_pytorch | 0 | Maxout | 3 |
18,816 | import torch
from types import SimpleNamespace
import torch.nn as nn
class MLP(nn.Module):
"""
多层感知机(MLP)模块,用于 Transformer 模型中的前馈神经网络部分。
MLP 模块由两个线性层和一个 GELU 激活函数组成,应用于 Transformer 块的残差连接之后。
"""
def __init__(self, config):
"""
初始化 MLP 模块。
参数:
config: 配置对象,包含以... | R_kgDONkz9jg | GPT-PyTorch | 1 | MLP | 2 |
18,897 | import torch
from torch import nn
class BaselineModel(nn.Module):
def __init__(self, input_size: int, output_size: int, hidden_units: int):
super().__init__()
self.prelu = nn.PReLU()
self.flatten = nn.Flatten()
self.layer_1 = nn.Linear(in_features=input_size, out_features=hidden_un... | R_kgDONlNDcw | learning-pytorch-from-daniel-bourke | 0 | BaselineModel | 2 |
18,558 | import torch
import torch.nn as nn
class MyNeuralNetwork(nn.Module):
def __init__(self):
super(MyNeuralNetwork, self).__init__()
self.fc1 = nn.Linear(6400, 6400)
self.fc2 = nn.Linear(6400, 100)
def forward(self, x):
x = torch.relu(self.fc1(x))
x = self.fc2(x)
r... | R_kgDONm4zTQ | dynamic_device_selector_pytorch | 2 | MyNeuralNetwork | 1 |
19,038 | import torch
import torch.nn as nn
class MLP(nn.Module):
"""
Following paper's detection head description:
Feed-forward network (FFN) for bounding box regression.
Note: Paper mentions using FFN for predictions but doesn't specify:
- Number of layers (we use 3 following DETR)
- Hidden dimen... | R_kgDONnIcsA | DECO | 3 | MLP | 1 |
18,869 | import torch
import torch.nn as nn
class CrossAttention(nn.Module):
def __init__(self, hidden_size, head_num=8):
super(CrossAttention, self).__init__()
self.head_num = head_num
self.s_d = hidden_size // self.head_num
self.all_head_size = self.head_num * self.s_d
self.Wq = n... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | CrossAttention | 3 |
18,598 | import torch
from torch import nn
from torch.nn import functional as F
# Dependent class from the same file
class SimplifiedLayerNorm(nn.Module):
def __init__(self, in_channels: int, eps=1e-06):
super().__init__()
self.weight = nn.Parameter(torch.ones(in_channels))
self.eps = eps
def ... | R_kgDONmLyPg | stable_diffusion_3.5-pytorch-implementation | 2 | FeedForward | 3 |
18,875 | import torch
import torch.nn as nn
class GGF(nn.Module):
def __init__(self, input_dim, intermediate_dim, output_dim):
super(GGF, self).__init__()
self.Wa = nn.Linear(input_dim, intermediate_dim)
self.Wv = nn.Linear(input_dim, intermediate_dim)
self.Wav = nn.Linear(input_dim, interm... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | GGF | 3 |
18,566 | import torch
import torch.nn as nn
class FeedForward(nn.Module):
def __init__(self, hidden_dim, ff_dim=None):
super().__init__()
if ff_dim is None:
ff_dim = hidden_dim * 4
self.linear1 = nn.Linear(hidden_dim, ff_dim)
self.linear2 = nn.Linear(ff_dim, hidden_dim)
... | R_kgDONlGiCw | pytorch-genie-world-model | 2 | FeedForward | 2 |
19,080 | import math
import torch
from torch.nn import Module, functional as F
from torch.nn.parameter import Parameter
class CosineLinear(Module):
def __init__(self, in_features: int, out_features: int, sigma: bool=True):
super(CosineLinear, self).__init__()
self.in_features = in_features
self.out... | R_kgDONlOr8A | graph-representation-learning | 0 | CosineLinear | 2 |
18,724 | import torch
import torch.nn as nn
class MyNN(nn.Module):
def __init__(self, in_size=256, layer_num=100):
super(MyNN, self).__init__()
self.in_size = in_size
self.FC = nn.Sequential(*[nn.Linear(in_size, in_size, bias=False) for _ in range(layer_num)])
self._initialize()
def fo... | R_kgDONnBN4g | pytorch_practice | 0 | MyNN | 1 |
19,081 | import math
import torch
from torch.nn import Module, functional as F
from torch.nn.parameter import Parameter
class GroupCosineLinear(Module):
def __init__(self, in_features: int, out_features: int, sigma: bool=True):
super(GroupCosineLinear, self).__init__()
self.in_features = in_features
... | R_kgDONlOr8A | graph-representation-learning | 0 | GroupCosineLinear | 3 |
19,060 | import torch
import numpy as np
from torch import nn
from torch.nn import functional as F
class RanPACLayer(nn.Module):
def __init__(self, input_dim, output_dim, lambda_value):
super(RanPACLayer, self).__init__()
self.projection = nn.Linear(input_dim, output_dim, bias=False)
for param in s... | R_kgDONlOr8A | graph-representation-learning | 0 | RanPACLayer | 2 |
19,006 | import torch
from torch import Tensor, nn
from torch.nn import functional as F
class Mlp(nn.Module):
def __init__(self, hidden_size: int, intermediate_size: int):
super().__init__()
self.gate_proj = nn.Linear(hidden_size, intermediate_size, bias=False)
self.up_proj = nn.Linear(hidden_size,... | R_kgDONk9RsQ | minrl | 1 | Mlp | 2 |
18,959 | import torch
from torch import nn
class ValueHead(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.ModuleList()
self.layers.append(nn.Linear(512, 128))
self.layers.append(nn.BatchNorm1d(num_features=128))
self.layers.append(nn.Sigmoid())
self.laye... | R_kgDONmyrfw | ml-chess | 0 | ValueHead | 2 |
18,622 | import torch
from torch import nn
class Three_Layer_MLP(nn.Module):
def __init__(self) -> None:
super().__init__()
self.MLP1 = nn.Linear(784, 128)
self.MLP2 = nn.Linear(128, 64)
self.MLP3 = nn.Linear(64, 10)
self.ReLU = nn.ReLU()
self.softmax = nn.Softmax(dim=-1)
... | R_kgDONl-h3g | hand-written-digit-recognition | 3 | Three_Layer_MLP | 2 |
18,621 | import torch
from torch import nn
class One_Layer_MLP(nn.Module):
def __init__(self) -> None:
super().__init__()
self.MLP = nn.Linear(784, 10)
self.softmax = nn.Softmax(dim=-1)
self.loss = nn.CrossEntropyLoss()
def forward(self, images: torch.Tensor, label: torch.Tensor):
... | R_kgDONl-h3g | hand-written-digit-recognition | 3 | One_Layer_MLP | 2 |
18,782 | import torch
class SVMModel(torch.nn.Module):
def __init__(self):
super().__init__()
self.weights = torch.nn.Parameter(torch.randn(2))
self.bias = torch.nn.Parameter(torch.zeros(1))
def forward(self, X):
return X @ self.weights + self.bias
def get_inputs():
return [torch.... | R_kgDONlNiSQ | py-svm-pytorch | 0 | SVMModel | 1 |
18,829 | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.distributions.normal import Normal
class ActorNet(nn.Module):
"""this is a NN that is going to be used to return the mean and standard deviations
of distribuitons of all the actions that are ... | R_kgDONlHOXA | Soft-Actor-Critic_pytorch | 0 | ActorNet | 2 |
18,923 | import torch
class Stage15(torch.nn.Module):
def __init__(self):
super(Stage15, self).__init__()
self.layer7 = torch.nn.Linear(in_features=4096, out_features=10, bias=True)
self._initialize_weights()
def forward(self, input0):
out0 = input0.clone()
out7 = self.layer7(o... | R_kgDONm36GQ | PipeOptim | 0 | Stage15 | 1 |
18,974 | import torch
import torch.nn as nn
class PaletteGenerator(nn.Module):
def __init__(self, noise_dim=100, output_dim=15):
super(PaletteGenerator, self).__init__()
self.model = nn.Sequential(nn.Linear(noise_dim, 128), nn.ReLU(), nn.Linear(128, 256), nn.ReLU(), nn.Linear(256, output_dim), nn.Sigmoid()... | R_kgDONmRkSw | palette_generator | 0 | PaletteGenerator | 2 |
18,652 | import torch
class FullyConnected(torch.nn.Module):
def __init__(self, input_size, output_size, activation_fn='linear'):
super(FullyConnected, self).__init__()
self.act_fn = activation_fn
self.relu = torch.nn.ReLU()
self.lrelu = torch.nn.LeakyReLU()
self.fc = torch.nn.Linea... | R_kgDONm8hnw | DL_Pytorch | 0 | FullyConnected | 1 |
18,525 | import torch
from torch import nn
class LinearLora(nn.Linear):
"""
LinearLora 类继承自 nn.Linear,添加了低秩自适应(LoRA)机制。
LoRA 通过在原始线性层的基础上添加低秩矩阵来实现高效微调,从而减少训练参数量并加速训练过程。
该类在前向传播过程中,将原始线性层的输出与 LoRA 矩阵的输出进行加和,实现低秩适应的效果。
参数:
in_features (int): 输入特征的维度。
out_features (int): 输出特征的维度。
bias... | R_kgDONnbfBg | FLUX-PyTorch | 3 | LinearLora | 2 |
18,554 | import torch
import torch.nn.functional as F
from torch import nn
class ConvChannelsMixer(nn.Module):
"""Linear activation block for PIPs's MLP Mixer."""
def __init__(self, in_channels):
super().__init__()
self.mlp2_up = nn.Linear(in_channels, in_channels * 4)
self.mlp2_down = nn.Linea... | R_kgDONmiq7A | TAPIR-pytorch | 2 | ConvChannelsMixer | 1 |
18,820 | import torch
from torch.nn import Linear
class HousingModel(torch.nn.Module):
def __init__(self, input_dim):
super(HousingModel, self).__init__()
self.linear = Linear(input_dim, 1)
def forward(self, x):
return self.linear(x)
def get_inputs():
return [torch.rand([4, 10])]
def get... | R_kgDONnu-Lg | linear-logistic-regressions | 0 | HousingModel | 1 |
18,929 | import torch
import torch.nn as nn
class Classifier(nn.Module):
"""
Fully-connected classifier
"""
def __init__(self, in_features, out_features, math='fp32'):
"""
Constructor for the Classifier.
:param in_features: number of input features
:param out_features: number o... | R_kgDONm36GQ | PipeOptim | 0 | Classifier | 1 |
18,827 | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class criticNetwork(nn.Module):
def __init__(self, in_dims, learning_rate, fc1_units=256, fc2_units=256, no_actions=2, name='critic', chk_file='tmp/sac'):
super(criticNetwork, self).__init__()
... | R_kgDONlHOXA | Soft-Actor-Critic_pytorch | 0 | criticNetwork | 2 |
18,781 | import torch
import torch.nn as nn
class SimpleNet(nn.Module):
"""Simple neural network for regression."""
def __init__(self):
super().__init__()
self.net = nn.Sequential(nn.Linear(10, 32), nn.ReLU(), nn.Linear(32, 16), nn.ReLU(), nn.Linear(16, 1))
def forward(self, x: torch.Tensor) -> to... | R_kgDONkd5zw | pytorch_basics_library | 1 | SimpleNet | 1 |
18,973 | import torch
import torch.nn as nn
class PaletteDiscriminator(nn.Module):
def __init__(self, input_dim=15):
super(PaletteDiscriminator, self).__init__()
self.model = nn.Sequential(nn.Linear(input_dim, 256), nn.LeakyReLU(0.2), nn.Linear(256, 128), nn.LeakyReLU(0.2), nn.Linear(128, 1), nn.Sigmoid())... | R_kgDONmRkSw | palette_generator | 0 | PaletteDiscriminator | 2 |
18,917 | import torch
class Stage1(torch.nn.Module):
def __init__(self):
super(Stage1, self).__init__()
self.layer1 = torch.nn.Linear(in_features=9216, out_features=4096, bias=True)
self.layer2 = torch.nn.ReLU(inplace=True)
self.layer3 = torch.nn.Dropout(p=0.5)
self.layer4 = torch.n... | R_kgDONm36GQ | PipeOptim | 0 | Stage1 | 2 |
18,873 | import torch
import torch.nn as nn
# Dependent class from the same file
class PositionWiseFeedForward(nn.Module):
"""
w2(relu(w1(layer_norm(x))+b1))+b2
"""
def __init__(self, TEXT_DIM, dropout=None):
super(PositionWiseFeedForward, self).__init__()
self.w_1 = nn.Linear(TEXT_DIM, 64)
... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | Conv1d4nonverbal | 2 |
18,898 | import torch
from torch import nn
# Dependent class from the same file
class SinusActivation(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return torch.sin(x)
# Dependent class from the same file
class DivXActivation(nn.Module):
def __init__(self):
sup... | R_kgDONlNDcw | learning-pytorch-from-daniel-bourke | 0 | CircleModelV1 | 2 |
18,805 | import torch
from torch import nn
class ClassificationHead(nn.Module):
def __init__(self, embed_dim, n_classes):
super().__init__()
self.classifier = nn.Linear(embed_dim, n_classes)
def forward(self, x):
return self.classifier(x[:, 0])
def get_inputs():
return [torch.rand([4, 5, ... | R_kgDONlQYzA | PyTorch-CLIP | 0 | ClassificationHead | 2 |
18,784 | import torch
import torch.nn as nn
class DynamicAerodynamicDNN(nn.Module):
def __init__(self, input_dim, hidden_units_per_layer, output_units, activation):
super(DynamicAerodynamicDNN, self).__init__()
layers = []
layers.append(nn.Linear(input_dim, hidden_units_per_layer[0]))
layer... | R_kgDONmQT6g | airfoil-ml-pytorch | 0 | DynamicAerodynamicDNN | 1 |
19,018 | import torch
class Dense(torch.nn.Module):
def __init__(self, in_channels, units, activation=None, use_bias=True, **kwargs):
super().__init__()
self.linear = torch.nn.Linear(in_channels, units, bias=use_bias)
if activation == 'relu':
self.activation = torch.nn.ReLU()
el... | R_kgDONkjAlw | Rex | 0 | Dense | 1 |
18,924 | import torch
class Stage14(torch.nn.Module):
def __init__(self):
super(Stage14, self).__init__()
self.layer4 = torch.nn.Linear(in_features=4096, out_features=4096, bias=True)
self.layer5 = torch.nn.ReLU(inplace=True)
self.layer6 = torch.nn.Dropout(p=0.5)
self._initialize_we... | R_kgDONm36GQ | PipeOptim | 0 | Stage14 | 2 |
19,022 | import torch
import torch.nn as nn
class testModel(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 128, 2, padding='same')
self.conv2 = nn.Conv2d(128, 256, padding='same', kernel_size=2)
self.fco = nn.Linear(28 ** 2 * 256, 10)
def forward(self, x):... | R_kgDONmPdyg | torchTrainify | 0 | testModel | 2 |
18,628 | import torch
import torch.nn as nn
import typing
# Dependent class from the same file
class MLP(nn.Module):
def __init__(self, input_dim, hidden_sizes: typing.Iterable[int], out_dim, activation_function=nn.Sigmoid(), activation_out=None):
super(MLP, self).__init__()
i_h_sizes = [input_dim] + hidde... | R_kgDONnkKtA | pytorch_gnn | 0 | StateTransition | 3 |
18,721 | import torch
import torch.nn as nn
import torch.nn.functional as F
class PortraitNet(nn.Module):
def __init__(self, input_dim, hidden_dim):
super(PortraitNet, self).__init__()
self.lstm = nn.LSTM(input_size=input_dim, hidden_size=hidden_dim, batch_first=True)
self.layernorm = nn.LayerNorm(... | R_kgDONmb_lg | msdmt-pytorch | 0 | PortraitNet | 2 |
18,932 | import torch
class Stage2(torch.nn.Module):
def __init__(self):
super(Stage2, self).__init__()
self.layer1 = torch.nn.Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer2 = torch.nn.ReLU(inplace=True)
self.layer3 = torch.nn.Conv2d(384, 256, kernel_size=(3... | R_kgDONm36GQ | PipeOptim | 0 | Stage2 | 2 |
19,035 | import torch
import torch.nn as nn
class DECOEncoderLayer(nn.Module):
"""
A single 'ConvNeXt-like' block used in the DECO encoder:
- Depthwise 7x7 (or other kernel_size)
- LayerNorm
- 1x1 conv
- GELU
- 1x1 conv
- Skip connection
"""
def __init__(self, dim: int, kernel_size: int... | R_kgDONnIcsA | DECO | 3 | DECOEncoderLayer | 2 |
19,093 | import torch
import torch.nn as nn
import torch.nn.functional as F
class ReprojectionLoss(nn.Module):
def __init__(self):
super().__init__()
def forward(self, predicts, targets, separate=False):
loss = F.mse_loss(input=predicts, target=targets, reduction='none')
return torch.mean(loss... | R_kgDONnWRwg | monodepth | 1 | ReprojectionLoss | 2 |
18,655 | import torch
import torch.nn as nn
class ConvDown(nn.Module):
def __init__(self, c_in, c_out):
super(ConvDown, self).__init__()
self.conv1 = nn.Conv2d(c_in, c_out, kernel_size=3, padding=1)
self.conv2 = nn.Conv2d(c_out, c_out, kernel_size=3, padding=1)
self.bn1 = nn.BatchNorm2d(c_o... | R_kgDONm8hnw | DL_Pytorch | 0 | ConvDown | 2 |
18,623 | import torch
from torch import nn
class ResidualConnectionWithConv(nn.Module):
def __init__(self, in_dim: int, hidden_size: int):
super().__init__()
self.conv3x3_1 = nn.Conv2d(in_channels=in_dim, out_channels=hidden_size, kernel_size=3, padding=1)
self.batchnorm_1 = nn.BatchNorm2d(num_feat... | R_kgDONl-h3g | hand-written-digit-recognition | 3 | ResidualConnectionWithConv | 2 |
18,531 | import torch
from torch import nn
class MEBasic(nn.Module):
def __init__(self):
super().__init__()
self.relu = nn.ReLU()
self.conv1 = nn.Conv2d(8, 32, 7, 1, padding=3)
self.conv2 = nn.Conv2d(32, 64, 7, 1, padding=3)
self.conv3 = nn.Conv2d(64, 32, 7, 1, padding=3)
se... | R_kgDONnVguA | DCVC-B | 20 | MEBasic | 1 |
18,870 | import torch
import torch.nn as nn
class GatedMultimodalLayerWithFFN(nn.Module):
def __init__(self, size_in1, size_in2, dropout, size_out=32):
super(GatedMultimodalLayerWithFFN, self).__init__()
self.hidden_sigmoid = nn.Linear(size_in1 * 2, 1)
self.tanh_f = nn.Tanh()
self.sigmoid_f... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | GatedMultimodalLayerWithFFN | 2 |
19,014 | import torch
class Conv2D(torch.nn.Module):
def __init__(self, in_channels, filters, kernel_size, strides=(1, 1), padding='same', use_bias=True, activation=None, dilation_rate=(1, 1), stride_offset=1, **kwargs):
super().__init__()
if padding == 'same' and strides in [2, (2, 2)]:
paddin... | R_kgDONkjAlw | Rex | 0 | Conv2D | 1 |
18,910 | import torch
class Stage5(torch.nn.Module):
def __init__(self):
super(Stage5, self).__init__()
self.layer14 = torch.nn.Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer15 = torch.nn.ReLU(inplace=True)
self._initialize_weights()
def forward(self, in... | R_kgDONm36GQ | PipeOptim | 0 | Stage5 | 2 |
18,722 | import torch
import torch.nn as nn
import torch.nn.functional as F
behavior_dim = 32
behavior_num = 101
maxlen = 64
timestep = 10
class BehaviorNet(nn.Module):
def __init__(self, behavior_num, emb_dim, maxlen, timestep, behavior_dim):
super(BehaviorNet, self).__init__()
self.emb = nn.Embedding(nu... | R_kgDONmb_lg | msdmt-pytorch | 0 | BehaviorNet | 3 |
18,726 | import torch
import torch.nn as nn
import torch.nn.functional as nnf
class LeNetGray(nn.Module):
def __init__(self):
super(LeNetGray, self).__init__()
self.conv1 = nn.Conv2d(1, 6, 5)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 5)
self.fc1 = nn.Linear(16 * 5... | R_kgDONnBN4g | pytorch_practice | 0 | LeNetGray | 3 |
18,866 | import torch
import torch.nn as nn
class SelfAttention(nn.Module):
def __init__(self, hidden_size, head_num=8):
super(SelfAttention, self).__init__()
self.head_num = head_num
self.s_d = hidden_size // self.head_num
self.all_head_size = self.head_num * self.s_d
self.Wq = nn.... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | SelfAttention | 3 |
18,796 | import torch
import torch.nn as nn
class EncoderBlock(nn.Module):
"""
编码器块(EncoderBlock)。
该模块实现了一个卷积编码器块,用于逐步下采样和提取图像特征。
"""
def __init__(self, base_channel):
"""
初始化编码器块。
参数:
base_channel (int): 基础通道数,用于定义每个卷积层的输出通道数。
"""
super().__init__()
... | R_kgDONmcLJw | VAE-PyTorch | 1 | EncoderBlock | 1 |
18,780 | import torch
import torch.nn as nn
class ConvNet(nn.Module):
"""Simple CNN architecture for demonstration."""
def __init__(self, in_channels: int=3):
super().__init__()
self.features = nn.Sequential(nn.Conv2d(in_channels, 32, kernel_size=3, padding=1), nn.BatchNorm2d(32), nn.ReLU(), nn.MaxPool... | R_kgDONkd5zw | pytorch_basics_library | 1 | ConvNet | 3 |
18,939 | import torch
from torch import Tensor, nn
def conv_block(in_channels: int, out_channels: int, pool: bool=False) -> nn.Module:
layers = [nn.Conv2d(in_channels, out_channels, kernel_size=3, padding=1), nn.ReLU(inplace=True)]
if pool:
layers.append(nn.MaxPool2d(2))
return nn.Sequential(*layers)
class... | R_kgDONmqDLw | TrainNets | 0 | cnn_small | 3 |
18,851 | import torch
import torch.nn as nn
LOWER = 5e-06
class Toy(nn.Module):
def __init__(self, scale=0.5):
super(Toy, self).__init__()
self.centers = torch.Tensor([[-3.0, 0], [3.0, 0]])
self.scale = scale
def forward(self, x, compute_grad=False):
x1 = x[0]
x2 = x[1]
... | R_kgDONm2Yew | EMTAL | 9 | Toy | 3 |
18,624 | import torch
from torch import nn
# Dependent class from the same file
class ResidualConnection(nn.Module):
def __init__(self, in_dim: int, hidden_size: int):
super().__init__()
self.conv3x3_1 = nn.Conv2d(in_channels=in_dim, out_channels=hidden_size, kernel_size=3, padding=1)
self.batchnor... | R_kgDONl-h3g | hand-written-digit-recognition | 3 | ResNet18 | 3 |
18,767 | import torch
import torch.nn as nn
class LightNN(nn.Module):
"""Lightweight neural network implementation to be used as student."""
def __init__(self, num_classes: int=10) -> None:
"""Initialize the lightweight neural network.
Args:
num_classes: Number of output classes
... | R_kgDONm7u9w | pytorch_knowledge_distill | 0 | LightNN | 3 |
18,848 | import torch
import torch.nn as nn
class RegressionHead(nn.Module):
def __init__(self, n_outputs, n_inputs=2048):
super(RegressionHead, self).__init__()
self.fc = nn.Linear(n_inputs, n_outputs, bias=True)
nn.init.kaiming_normal_(self.fc.weight)
if self.fc.bias is not None:
... | R_kgDONm2Yew | EMTAL | 9 | RegressionHead | 1 |
18,765 | import torch
import torch.nn as nn
class CosineEmbeddingDeepNN(nn.Module):
"""Deep neural network implementation to be used as teacher."""
def __init__(self, num_classes: int=10) -> None:
"""Initialize the deep neural network.
Args:
num_classes: Number of output classes
... | R_kgDONm7u9w | pytorch_knowledge_distill | 0 | CosineEmbeddingDeepNN | 3 |
19,102 | import torch
import torch.nn as nn
class ProjectionLinearLayer(torch.nn.Module):
def __init__(self, dec_output_dim: int, vocab_size: int, dropout: float=0.1):
super(ProjectionLinearLayer, self).__init__()
self.proj = nn.Linear(dec_output_dim, vocab_size)
self.dropout = nn.Dropout(dropout)
... | R_kgDONmli4w | transformer_implemenatation | 0 | ProjectionLinearLayer | 1 |
18,659 | import torch
import torch.nn as nn
# Dependent class from the same file
class ConvDPUnit(nn.Module):
def __init__(self, in_channels, out_channels, withBNRelu=True):
super(ConvDPUnit, self).__init__()
self.in_channels = in_channels
self.out_channels = out_channels
self.conv1 = nn.Co... | R_kgDONnqJcQ | yunet_pytorch | 0 | Conv_head | 2 |
19,078 | import torch
from torch import nn
class Discriminator(nn.Module):
def __init__(self, input_dim):
super().__init__()
self.bilinear = nn.Bilinear(input_dim, input_dim, 1)
self.input_dim = input_dim
for m in self.modules():
self.weights_init(m)
def weights_init(self, ... | R_kgDONlOr8A | graph-representation-learning | 0 | Discriminator | 2 |
18,660 | import torch
import torch.nn as nn
# Dependent class from the same file
class ConvDPUnit(nn.Module):
def __init__(self, in_channels, out_channels, withBNRelu=True):
super(ConvDPUnit, self).__init__()
self.in_channels = in_channels
self.out_channels = out_channels
self.conv1 = nn.Co... | R_kgDONnqJcQ | yunet_pytorch | 0 | Conv4layerBlock | 2 |
18,888 | import torch
import torch.nn as nn
# Simplified implementation of dependent class Swish
class Swish(nn.Module):
def __init__(self, *args, **kwargs):
super().__init__()
for key, value in kwargs.items():
setattr(self, key, value)
def forward(self, x):
return x
class FFN(nn.M... | R_kgDONmuGkg | best-rq | 0 | FFN | 2 |
18,794 | import torch
import torch.nn as nn
class UpsampleDecoder(nn.Module):
"""
上采样解码器(UpsampleDecoder)。
该模块实现了一个使用上采样和卷积层的解码器,用于将潜在空间表示逐步上采样并转换为原始图像。
"""
def __init__(self, latent_dim):
"""
初始化上采样解码器。
参数:
latent_dim (int): 潜在空间的维度。
"""
super().__init... | R_kgDONmcLJw | VAE-PyTorch | 1 | UpsampleDecoder | 3 |
18,941 | import torch
from torch import Tensor, nn
from typing import Callable, Optional
# Dependent class from the same file
class Sine(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x: Tensor) -> Tensor:
return torch.sin(x)
class MLP(nn.Module):
"""
Multi Layer P... | R_kgDONmqDLw | TrainNets | 0 | MLP | 2 |
18,863 | import torch
import torch.nn as nn
class MultiModalShiftGate(nn.Module):
def __init__(self, dim, mu=0.5, ep=1e-07):
super(MultiModalShiftGate, self).__init__()
self.proj = nn.Linear(2 * dim, dim)
self.mu = nn.Parameter(torch.tensor([mu]))
self.ep = ep
def forward(self, t, a, v... | R_kgDONkfJig | SomeModuleImplementedInPytorch | 1 | MultiModalShiftGate | 3 |
18,654 | import torch
import torch.nn as nn
class PSPModule(nn.Module):
def __init__(self, c_in):
super(PSPModule, self).__init__()
self.avgp1 = nn.AdaptiveAvgPool2d(output_size=(1, 1))
self.conv1 = nn.Conv2d(c_in, c_in // 4, kernel_size=1)
self.avgp2 = nn.AdaptiveAvgPool2d(output_size=(2, ... | R_kgDONm8hnw | DL_Pytorch | 0 | PSPModule | 3 |
18,922 | import torch
class Stage7(torch.nn.Module):
def __init__(self):
super(Stage7, self).__init__()
self.layer19 = torch.nn.Conv2d(256, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer20 = torch.nn.ReLU(inplace=True)
self._initialize_weights()
def forward(self, in... | R_kgDONm36GQ | PipeOptim | 0 | Stage7 | 2 |
18,763 | import torch
import torch.nn as nn
class DeepNN(nn.Module):
"""Deep neural network implementation to be used as teacher."""
def __init__(self, num_classes: int=10) -> None:
"""Initialize the deep neural network.
Args:
num_classes: Number of output classes
"""
... | R_kgDONm7u9w | pytorch_knowledge_distill | 0 | DeepNN | 3 |
19,162 | import torch
import torch.nn as nn
import torch.nn.functional as F
class Fer2013(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 64, kernel_size=3, padding=1)
self.conv2 = nn.Conv2d(64, 64, kernel_size=3, padding=1)
self.pool1 = nn.MaxPool2d(2, stride=2... | R_kgDONlvAow | python-math | 1 | Fer2013 | 3 |
18,933 | import torch
class Stage10(torch.nn.Module):
def __init__(self):
super(Stage10, self).__init__()
self.layer26 = torch.nn.Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer27 = torch.nn.ReLU(inplace=True)
self._initialize_weights()
def forward(self, ... | R_kgDONm36GQ | PipeOptim | 0 | Stage10 | 2 |
18,766 | import torch
import torch.nn as nn
class ModifiedDeepRegressorNN(nn.Module):
"""Deep neural network with regressor implementation to be used as teacher."""
def __init__(self, num_classes: int=10) -> None:
"""Initialize the deep neural network.
Args:
num_classes: Number of ... | R_kgDONm7u9w | pytorch_knowledge_distill | 0 | ModifiedDeepRegressorNN | 3 |
19,067 | import torch
from torch import nn
def make_linear_relu(input_dim, output_dim):
return nn.Sequential(nn.Linear(input_dim, output_dim), nn.ReLU())
class NodeSelfAtten(nn.Module):
def __init__(self, input_dim):
super(NodeSelfAtten, self).__init__()
self.F = input_dim
self.f = make_linear... | R_kgDONlOr8A | graph-representation-learning | 0 | NodeSelfAtten | 3 |
18,927 | import torch
class Stage11(torch.nn.Module):
def __init__(self):
super(Stage11, self).__init__()
self.layer28 = torch.nn.Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer29 = torch.nn.ReLU(inplace=True)
self._initialize_weights()
def forward(self, ... | R_kgDONm36GQ | PipeOptim | 0 | Stage11 | 2 |
18,512 | import torch
from torch import nn
class Convnet(nn.Module):
"""Convnet for fashion articles classification"""
def __init__(self, conv2d_kernel_size=3):
super().__init__()
self.layer_stack = nn.Sequential(nn.Conv2d(in_channels=1, out_channels=32, kernel_size=conv2d_kernel_size), nn.ReLU(), nn.M... | R_kgDONml3nA | pytorch-tutorial | 0 | Convnet | 2 |
18,785 | import torch
import torch.nn as nn
import torch.nn.functional as F
class VGGBlock(nn.Module):
"""Basic VGG block with optional batch normalization."""
def __init__(self, in_channels, out_channels, kernel_size, batch_normalization=True, kernel_reg=0.0, **kwargs):
"""Initialize the VGG block.
... | R_kgDONlQ1BA | Pytorch_SuperPoint | 0 | VGGBlock | 2 |
18,921 | import torch
class Stage9(torch.nn.Module):
def __init__(self):
super(Stage9, self).__init__()
self.layer23 = torch.nn.Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
self.layer24 = torch.nn.ReLU(inplace=True)
self.layer25 = torch.nn.MaxPool2d(kernel_size=2, str... | R_kgDONm36GQ | PipeOptim | 0 | Stage9 | 2 |
No dataset card yet