repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/singlecoil_mri.py | import torch, numbers, math
import torch.nn as nn
import torch.nn.functional as torchfunc
from operators.operator import LinearOperator
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and imaginary parts
are stacked along the ... | 15,854 | 31.623457 | 99 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/operators/blurs.py | import numpy as np
import numbers
import math
import cv2
import torch
import torch.nn.functional as torchfunc
from operators.operator import LinearOperator
class GaussianBlur(LinearOperator):
def __init__(self, sigma, kernel_size=5, n_channels=3, n_spatial_dimensions = 2):
super(GaussianBlur, self).__init_... | 3,604 | 47.716216 | 111 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/broyd_equilibrium_utils.py | import torch.nn as nn
import torch
import matplotlib
#matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import imageio
import numpy as np
from PIL import Image
def _safe_norm(v):
if not torch.isfinite(v).all():
return np.inf
return torch.norm(v)
def scalar_search_armijo(phi, phi0, derphi0... | 17,348 | 34.478528 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/equilibrium_nets.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
class EquilibriumGrad(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1, minval = -1, maxval = 1):
super(EquilibriumGrad,self).__init__()
self.linear_op = linear_operator
... | 3,395 | 39.915663 | 123 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/proxgrad.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
from PIL import Image
import imageio
import numpy as np
tt=0
class ProxgradNet(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1):
super(ProxgradNet,self).__init__()
self.linear_... | 9,973 | 48.376238 | 134 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/gradnet.py | import torch.nn as nn
import torch
from solvers.cg_utils import conjugate_gradient
from PIL import Image
import imageio
import numpy as np
tt = 0
class GradNet(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta_initial_val=0.1):
super(GradNet,self).__init__()
self.linear_op = li... | 6,039 | 45.10687 | 135 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/new_equilibrium_utils.py | import torch.nn as nn
import torch
import matplotlib
#matplotlib.use("TkAgg")
from matplotlib import pyplot as plt
import imageio
import numpy as np
from PIL import Image
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if comple... | 12,873 | 33.239362 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/cg_utils.py | import torch.nn as nn
import torch
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if complexdata:
# y = complex_conj(y)
return torch.sum(x*y,dim=[1,2,3])
def single_cg_iteration(x, d, g, b, ATA, regularization_lambda):... | 2,165 | 29.507042 | 89 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/solvers/equilibrium_solvers.py | import torch.nn as nn
import torch
import matplotlib
# matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
from solvers.cg_utils import conjugate_gradient
class EquilibriumGrad(nn.Module):
def __init__(self, linear_operator, nonlinear_operator, eta, minval = -1, maxval = 1):
super(EquilibriumGrad,self... | 13,787 | 36.16442 | 122 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/fastmri_dataloader.py | import torch
from torch.utils.data import Dataset, DataLoader
import numpy as np
import os, re, random, h5py, ismrmrd
from PIL import Image
from torch.utils.data import Dataset
from utils import forward_models_mri
def directory_filelist(target_directory):
file_list = [f for f in os.listdir(target_directory)
... | 6,291 | 35.581395 | 99 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/celeba_dataloader.py | import torch
from torch.utils.data import Dataset, DataLoader
import numpy as np
import os, re, random
from PIL import Image
def swap_patches(batch, index1, index2, h,w, patch_top_loc, patch_left_loc):
tmp = batch[
index1,
patch_top_loc:patch_top_loc+h,
patch_left_loc:patch_left_loc+w, :].clon... | 5,423 | 33.769231 | 101 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/testing_utils.py | from PIL import Image
import torch
import matplotlib.pyplot as plt
import numpy as np
import imageio
from PIL import Image
def save_tensor_as_color_img(img_tensor, filename):
np_array = img_tensor.cpu().detach().numpy()
imageio.save(filename, np_array)
def save_batch_as_color_imgs(tensor_batch, batch_size, ii... | 2,513 | 40.9 | 106 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/spectral_norm.py | """
Spectral Normalization borrowed from https://arxiv.org/abs/1802.05957
Real SN by convolution. Each layer has lipschtz constant of 1
"""
import torch
from torch.nn.functional import conv2d, conv_transpose2d
from torch.nn.parameter import Parameter
# import argparse
# from ..train_realSN import opt
# import torch.ji... | 20,664 | 42.141962 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/forward_models_mri.py | import torch, numbers, math
import torch.nn as nn
import torch.nn.functional as torchfunc
import numpy as np
import cv2
import numpy as np
import torch
def to_tensor(data):
"""
Convert numpy array to PyTorch tensor. For complex arrays, the real and imaginary parts
are stacked along the last dimension.
... | 21,838 | 33.446372 | 119 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/spectral_norm_chen.py | """
Spectral Normalization borrowed from https://arxiv.org/abs/1802.05957
Real SN by convolution. Each layer has lipschtz constant of 1
"""
import torch
from torch.nn.functional import conv2d
from torch.nn.parameter import Parameter
def normalize(tensor, eps=1e-12):
norm = float(torch.sqrt(torch.sum(tensor * tenso... | 7,791 | 43.272727 | 120 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/bsd500.py | import torch
import h5py
import random
import numpy as np
import os
from PIL import Image
from torchvision import transforms
class Dataset(torch.utils.data.Dataset):
def __init__(self, train=True, mode='S'):
super(Dataset, self).__init__()
self.train = train
self.mode = mode
self.da... | 3,858 | 34.731481 | 98 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/utils/cg_utils.py | import torch.nn as nn
import torch
def complex_conj(x):
assert x.shape[1] == 2
return torch.stack((x[:,0, ...], -x[:,1,...]), dim=1)
def torchdotproduct(x,y):
# if complexdata:
# y = complex_conj(y)
return torch.sum(x*y,dim=[1,2,3])
def single_cg_iteration(x, d, g, b, ATA, regularization_lambda):... | 2,165 | 29.507042 | 89 | py |
deep_equilibrium_inverse | deep_equilibrium_inverse-main/pytorch_ssim/__init__.py | import torch
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
from math import exp
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)])
return gauss/gauss.sum()
def create_window(window_size,... | 2,635 | 34.621622 | 104 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/models/base/jit_functions.py | import numba
import math
@numba.jit(nopython=True)
def _L1_clip(total_grads, reg_alpha):
"""
L1 regularisation on the gradients, controlled by self.reg_alpha
:param total_grads:
:return:
"""
if total_grads > reg_alpha:
return total_grads - reg_alpha
elif total_grads < -1 * reg_alph... | 1,972 | 34.872727 | 281 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/federated_gbdt/models/gbdt/private_gbdt.py | import math
import random
import sys
import pandas as pd
import numpy as np
from collections import Counter, defaultdict
from copy import copy
from fast_histogram import histogram1d
from federated_gbdt.models.base.tree_base import TreeBase
from federated_gbdt.models.base.tree_node import DecisionNode
from federated... | 57,288 | 61.748083 | 346 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/experiments/paper_experiments/paper_experiments.py | import math
import numpy as np
from experiments.experiment_helpers.data_loader import DataLoader
from experiments.experiment_helpers.experiment_runner import ExperimentRunner
from dev.communication_framework import CommunicationsFramework
global_seeds = [1, 4, 100, 333, 1002]
data_loader = DataLoader([1, 4, 100, 333... | 63,493 | 50.537338 | 224 | py |
federated-boosted-dp-trees | federated-boosted-dp-trees-master/experiments/paper_experiments/paper_plotter.py | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import os
import shutil
import matplotlib.lines as mlines
from collections import defaultdict
sns.set_theme(style="whitegrid")
def set_fontsize(size=14):
tex_fonts = {
#"text.usetex": True,
"font.family"... | 112,721 | 38.704826 | 472 | py |
drizzlepac | drizzlepac-master/doc/source/conf.py | # -*- coding: utf-8 -*-
#
# STSCI documentation build configuration file, created by
# sphinx-quickstart on Thu Oct 22 17:25:41 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All... | 10,719 | 32.08642 | 143 | py |
GNNs-for-NLP | GNNs-for-NLP-master/pytorch_gcn.py | from utils import *
import os.path as osp
import torch
import torch.nn.functional as F
from torch_geometric.datasets import Planetoid
import torch_geometric.transforms as T
from torch_geometric.nn import GCNConv
class KipfGCN(torch.nn.Module):
def __init__(self, data, num_class, params):
super(KipfGCN, self).__ini... | 7,611 | 29.448 | 139 | py |
cryptorandom | cryptorandom-main/doc/conf.py | #
# cryptorandom documentation build configuration file, created by
# sphinx-quickstart on Fri Oct 21 12:13:15 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration va... | 9,156 | 31.017483 | 79 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/dataset/dataset.py | import numpy as np
import os
import time
import sys
from tqdm import tqdm
import cv2
import torch
from torch.utils.data import Dataset, DataLoader
from albumentations.pytorch import ToTensor, ToTensorV2
from albumentations import (
Compose, HorizontalFlip, CLAHE, HueSaturationValue, Normalize, RandomBrightnessContr... | 11,928 | 38.369637 | 139 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/train/train_add_data_my_aug.py | import sys
sys.path.append('..')
import os
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
from torch.utils.data import *
import time
from model.models import get_efficientnet
from dataset.dataset import DeeperForensicsDataset, get_train_transforms, get_valid_transfor... | 12,235 | 51.741379 | 134 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/train/train_add_data.py | import sys
sys.path.append('..')
import os
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
from torch.utils.data import DataLoader
import time
from model.models import get_efficientnet
from dataset.dataset import DeeperForensicsDataset, get_train_transforms, get_valid... | 11,868 | 50.829694 | 134 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/train/train.py | import sys
sys.path.append('..')
import os
import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
from torch.utils.data import *
import time
from model.models import get_efficientnet
from dataset.dataset import DeeperForensicsDataset, get_train_transforms, get_valid_transfor... | 7,130 | 38.181319 | 111 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/loss/losses.py | import torch
import torch.nn as nn
class LabelSmoothing(nn.Module):
def __init__(self, smoothing=0.05):
super(LabelSmoothing, self).__init__()
self.confidence = 1.0 - smoothing
self.smoothing = smoothing
def forward(self, x, target):
if self.training:
x = x.float()
... | 743 | 27.615385 | 76 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/utils/utils.py | import tensorboardX
from sklearn.metrics import log_loss, accuracy_score, precision_score, average_precision_score, roc_auc_score, recall_score
import torch
class Logger(object):
def __init__(self, model_name, header):
self.header = header
self.writer = tensorboardX.SummaryWriter(model_name)
d... | 1,368 | 31.595238 | 123 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/data/detect_face.py | """ Tensorflow implementation of the face detection / alignment algorithm found at
https://github.com/kpzhang93/MTCNN_face_detection_alignment
"""
# MIT License
#
# Copyright (c) 2016 David Sandberg
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated docu... | 31,714 | 39.556266 | 150 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/model/models.py | import torch
import pretrainedmodels
import torch.nn as nn
from torch.nn import init
import torchvision
from efficientnet_pytorch import EfficientNet
import torch.nn.functional as F
import numpy as np
import math
def get_efficientnet(model_name='efficientnet-b0', num_classes=2, pretrained=True):
if pretrained:
... | 927 | 24.777778 | 107 | py |
DeeperForensicsChallengeSolution | DeeperForensicsChallengeSolution-master/model/toy_predict.py | import sys
sys.path.append('..')
from eval_kit.detector import DeeperForensicsDetector
from model.models import get_efficientnet
import torch
import time
import glob
from PIL import Image
import torchvision.transforms as transforms
from facenet_pytorch import MTCNN, extract_face
import torch.nn as nn
from model.face_... | 11,159 | 34.884244 | 113 | py |
AAAI-23.6040 | AAAI-23.6040-master/scripts/prediction_stepmania.py | import argparse
import json
import logging
import tempfile
from ast import literal_eval
from logging import getLogger
from pathlib import Path
from typing import Dict, List, Tuple
import numpy as np
import pandas as pd
import torch
from notes_generator.constants import ConvStackType, NMELS
from notes_generator.models... | 4,249 | 28.929577 | 84 | py |
AAAI-23.6040 | AAAI-23.6040-master/scripts/model_test.py | import argparse
import os
from datetime import datetime
from pathlib import Path
from torch.utils.data.dataloader import DataLoader
from notes_generator.constants import *
from notes_generator.models.onsets import SimpleOnsets
from notes_generator.training.evaluate import evaluate_test
from notes_generator.training.l... | 5,789 | 30.639344 | 118 | py |
AAAI-23.6040 | AAAI-23.6040-master/scripts/onsets_train.py | import argparse
import logging
from collections import OrderedDict
from datetime import datetime
from pathlib import Path
import mlflow
import torch
from torch.optim.lr_scheduler import CosineAnnealingLR, CyclicLR
from torch.utils.data.dataloader import DataLoader
from torch.utils.tensorboard import SummaryWriter
fro... | 8,247 | 39.431373 | 99 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/training/evaluate.py | import sys
from collections import defaultdict
from typing import List, Type
import numpy as np
import torch
from mir_eval.onset import f_measure as evaluate_onset
from mir_eval.transcription import match_notes, precision_recall_f1_overlap as evaluate_notes
from mir_eval.util import midi_to_hz
from notes_generator.co... | 11,028 | 33.145511 | 94 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/training/model_tester.py | import csv
import os
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, TextIO, Type, Union
import mlflow
import torch
import torch.multiprocessing as mp
import yaml
from torch import nn
from torch.utils.data.dataloader import DataLoader
from notes_generator.constants import *
LoaderC... | 16,385 | 34.777293 | 124 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/training/augmenation.py | import math
import typing
from pathlib import Path
import numpy as np
import torch
import torch.nn.functional as F
import torchaudio.functional as AF
import torchaudio.transforms as T
import yaml
from notes_generator.constants import FRAME, NMELS
Sample = typing.Dict[str, torch.Tensor]
class AugConfig(typing.Named... | 5,571 | 30.480226 | 94 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/training/loader.py | import json
import random
import warnings
from pathlib import Path
from typing import Dict, Optional, Tuple
import numpy as np
import torch
from notes_generator.constants import *
from notes_generator.models.beats import gen_beats_array
from notes_generator.training import augmenation
def load(base_dir: Path, app_n... | 20,358 | 34.101724 | 100 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/training/train.py | import math
import shutil
import typing
from logging import getLogger
from pathlib import Path
import mlflow
import numpy as np
import torch
from ignite.engine import Engine, Events
from ignite.handlers import Checkpoint, DiskSaver, EarlyStopping, ModelCheckpoint
from ignite.metrics import Average
from torch.nn.utils ... | 9,367 | 36.774194 | 98 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/models/merge_labels.py | import typing
import torch
def merge_labels(onset_label: torch.Tensor, batch: typing.Dict, scale: float) -> torch.Tensor:
assert "other_conditions" in batch
other_conditions = batch["other_conditions"]
for condition, score in other_conditions.items():
onset_label = torch.max(onset_label, score * ... | 350 | 28.25 | 94 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/models/fuzzy_label.py | import torch
import torch.nn.functional as F
from notes_generator.models.util import round_decimal
def shift(ar, size, med):
# [0, 0, 0, 1, 0, 0...]
# -> [0, 0, med - 1, 0, mid - 1, 0 ...]
if size > 0:
ar = F.pad(ar[size:], [0, size]) + F.pad(ar[:-size], [size, 0])
ar = ar * (med - size)
... | 2,107 | 27.876712 | 96 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/models/onsets.py | import typing
import torch
from torch import nn
from torch.nn import functional as F
from notes_generator.constants import *
from notes_generator.layers.base_layers import BiLSTM, get_conv_stack
from notes_generator.models.fuzzy_label import fuzzy_on_batch
from notes_generator.models.merge_labels import merge_labels
... | 9,076 | 33.25283 | 97 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/models/util.py | import typing
import torch
from torch import nn
def round_decimal(x: torch.Tensor, n_dig: int) -> torch.Tensor:
return torch.round(x * 10**n_dig) / (10**n_dig)
def batch_first(data):
shapes = [-1] + list(data.shape[1:])
return data.reshape(*shapes)
def initialize_weights(m):
if hasattr(m, "weight... | 1,220 | 24.4375 | 95 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/layers/base_layers.py | import typing
import torch
from torch import nn
from notes_generator.constants import ConvStackType, NMELS
from notes_generator.layers.drop import DropBlock2d
class BiLSTM(nn.Module):
"""Bidirectional LSTM Stack
Parameters
----------
input_features : int
The number of expected features in t... | 14,245 | 33.916667 | 99 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/layers/transformer_layers.py | # https://github.com/novdov/music-transformer/blob/master/music_transformer/modules/attention.py
import math
from typing import List, Optional, Tuple
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
class MultiheadAttention(nn.Module):
"""Apply multi-head attention to input d... | 26,512 | 34.925474 | 99 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/layers/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
def __init__(self, d_model: int, dropout: float = 0.1):
super(Attention, self).__init__()
self.d_model = d_model
projection_inout = (self.d_model, self.d_model)
self.query_projection = nn... | 1,484 | 32.75 | 64 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/layers/drop.py | # https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/layers/drop.py
""" DropBlock, DropPath
PyTorch implementations of DropBlock and DropPath (Stochastic Depth) regularization layers.
Papers:
DropBlock: A regularization method for convolutional networks (https://arxiv.org/abs/1810.12890)
Deep Net... | 7,452 | 33.345622 | 108 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/prediction/predictor.py | import logging
from logging import getLogger
from typing import Callable, Dict, List, Optional
from typing import Tuple, Union
import numpy as np
import torch
from notes_generator.constants import (
FRAME,
MAX_THRESHOLD,
SMDifficultyType,
SMNotesType,
sm_init_threshold,
sm_max_notes,
sm_mi... | 12,884 | 29.246479 | 114 | py |
AAAI-23.6040 | AAAI-23.6040-master/notes_generator/prediction/onset_prediction.py | from typing import List, Optional, Tuple, Union
import numpy as np
import torch
from notes_generator.constants import ConvStackType
from notes_generator.models.beats import gen_beats_array
def predict(
model,
mel,
condition: int,
threshold: float = 0.5,
bpm_info: Optional[List[Tuple[Union[float,... | 1,516 | 28.173077 | 91 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/main.py | import argparse
import os
import time
import math
import ast
import numpy as np
import torch
import torch.nn as nn
import gc
import data
import model
from utils import batchify, get_batch, repackage_hidden, create_exp_dir, save_checkpoint
parser = argparse.ArgumentParser(description='PyTorch PennTreeBank/WikiText2... | 17,738 | 42.584767 | 164 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/evaluate.py | import argparse
import os
import time
import math
import csv
import ast
import pickle
import numpy as np
import torch
import torch.nn as nn
import data
import model
from utils import batchify, get_batch, repackage_hidden
parser = argparse.ArgumentParser(description='PyTorch PennTreeBank/WikiText2 RNN/LSTM Language M... | 17,935 | 40.614849 | 132 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/dynamiceval.py | import argparse
import time
import math
import numpy as np
import os
import csv
import torch
import pickle
import torch.nn as nn
from torch.autograd import Variable
import data
parser = argparse.ArgumentParser(description='PyTorch PennTreeBank RNN/LSTM Language Model')
parser.add_argument('--data', type=str, default=... | 14,131 | 32.251765 | 130 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/generate.py | ###############################################################################
# Language Modeling on Penn Tree Bank
#
# This file generates new sentences sampled from the language model
#
###############################################################################
import argparse
import torch
from torch.autograd... | 2,610 | 33.813333 | 88 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/locked_dropout.py | import torch
import torch.nn as nn
from torch.autograd import Variable
class LockedDropout(nn.Module):
def __init__(self):
super().__init__()
def forward(self, x, dropout=0.5):
if not self.training or not dropout:
return x
m = x.data.new(1, x.size(1), x.size(2)).bernoulli_(... | 522 | 29.764706 | 71 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/utils.py | import os, shutil
import torch
from torch.autograd import Variable
def repackage_hidden(h):
"""Wraps hidden states in new Variables, to detach them from their history."""
if type(h) == Variable:
return Variable(h.data)
else:
return tuple(repackage_hidden(v) for v in h)
def batchify(data, b... | 1,845 | 36.673469 | 87 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/model.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from embed_regularize import embedded_dropout
from locked_dropout import LockedDropout
from weight_drop import WeightDrop
class RNNModel(nn.Module):
"""Container module with an encoder, a recurrent m... | 4,848 | 36.3 | 139 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/data.py | import os
import torch
from collections import Counter
class Dictionary(object):
def __init__(self):
self.word2idx = {}
self.idx2word = []
self.counter = Counter()
self.total = 0
def add_word(self, word):
if word not in self.word2idx:
self.idx2word.append(... | 3,989 | 29.692308 | 80 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/finetune.py | import argparse
import ast
import time
import math
import numpy as np
np.random.seed(331)
import torch
import torch.nn as nn
import data
import model
import os
from utils import batchify, get_batch, repackage_hidden, save_checkpoint
parser = argparse.ArgumentParser(description='PyTorch PennTreeBank/WikiText2 RNN/LST... | 14,244 | 42.696319 | 132 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/weight_drop.py | import torch
from torch.nn import Parameter
from functools import wraps
class WeightDrop(torch.nn.Module):
def __init__(self, module, weights, dropout=0, variational=False):
super(WeightDrop, self).__init__()
self.module = module
self.weights = weights
self.dropout = dropout
... | 3,199 | 31 | 94 | py |
gradual-learning-rnn | gradual-learning-rnn-master/pytorch_impl/embed_regularize.py | import numpy as np
import torch
from torch.autograd import Variable
def embedded_dropout(embed, words, dropout=0.1, scale=None):
if dropout:
mask = embed.weight.data.new().resize_((embed.weight.size(0), 1)).bernoulli_(1 - dropout).expand_as(embed.weight) / (1 - dropout)
mask = Variable(mask)
masked_embe... | 1,089 | 24.952381 | 133 | py |
sequer | sequer-main/code/tensor2tensor/setup.py | """Install tensor2tensor."""
from setuptools import find_packages
from setuptools import setup
setup(
name='tensor2tensor',
version='1.14.1',
description='Tensor2Tensor',
author='Google Inc.',
author_email='no-reply@google.com',
url='http://github.com/tensorflow/tensor2tensor',
license='Ap... | 3,012 | 29.434343 | 84 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/envs/env_problem_utils.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 9,598 | 35.086466 | 80 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/layers/common_layers.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 141,390 | 33.168922 | 109 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/layers/common_image_attention_test.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 6,040 | 37.234177 | 80 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/layers/ngram.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 3,605 | 37.774194 | 80 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/layers/modalities.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 59,324 | 38.39243 | 80 | py |
sequer | sequer-main/code/tensor2tensor/tensor2tensor/rl/batch_dqn_agent_test.py | # coding=utf-8
# Copyright 2019 The Tensor2Tensor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 6,005 | 36.773585 | 80 | py |
nlp-architect | nlp-architect-master/setup.py | #!/usr/bin/env python
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
... | 3,486 | 31.287037 | 112 | py |
nlp-architect | nlp-architect-master/examples/sparse_gnmt/gnmt/model_helper.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 29,803 | 35.346341 | 100 | py |
nlp-architect | nlp-architect-master/examples/intent_extraction/train_mtl_model.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 6,041 | 37 | 100 | py |
nlp-architect | nlp-architect-master/examples/intent_extraction/train_seq2seq_model.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 5,153 | 36.620438 | 99 | py |
nlp-architect | nlp-architect-master/examples/supervised_sentiment/example_ensemble.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 5,238 | 33.24183 | 100 | py |
nlp-architect | nlp-architect-master/examples/supervised_sentiment/supervised_sentiment.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 4,413 | 35.180328 | 97 | py |
nlp-architect | nlp-architect-master/examples/supervised_sentiment/optimize_example.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 4,985 | 34.112676 | 100 | py |
nlp-architect | nlp-architect-master/examples/chunker/train.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 6,774 | 33.92268 | 100 | py |
nlp-architect | nlp-architect-master/examples/ner/train.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 6,991 | 35.994709 | 100 | py |
nlp-architect | nlp-architect-master/solutions/InterpreT/application/tasks.py | # ******************************************************************************
# Copyright 2020-2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 30,547 | 42.953957 | 145 | py |
nlp-architect | nlp-architect-master/docs-source/source/conf.py | # -*- coding: utf-8 -*-
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License a... | 9,982 | 32.166113 | 103 | py |
nlp-architect | nlp-architect-master/tests/test_quantization.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 18,267 | 41.385151 | 100 | py |
nlp-architect | nlp-architect-master/tests/test_data_utils.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 2,991 | 45.030769 | 92 | py |
nlp-architect | nlp-architect-master/tests/test_ner_taggers.py | import argparse
import os
import tempfile
import shutil
import torch
from nlp_architect.procedures import TrainTagger
from nlp_architect.nn.torch.modules.embedders import IDCNN, CNNLSTM
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
DATA_DIR = os.path.join(CURRENT_DIR, "fixtures/conll_sample")
OUTPUT_DIR =... | 4,727 | 26.017143 | 99 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/quantization.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 14,729 | 37.25974 | 106 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/__init__.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 1,518 | 32.755556 | 89 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/distillation.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 4,826 | 31.18 | 99 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/modules/embedders.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 13,627 | 37.497175 | 100 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/layers/crf.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 15,085 | 42.982507 | 99 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/layers/__init__.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 813 | 44.222222 | 80 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/torch/data/dataset.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 3,336 | 35.67033 | 98 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/tensorflow/python/keras/callbacks.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 1,848 | 34.557692 | 80 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/tensorflow/python/keras/layers/crf.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 5,223 | 40.133858 | 95 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/tensorflow/python/keras/utils/layer_utils.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 2,012 | 35.6 | 81 | py |
nlp-architect | nlp-architect-master/nlp_architect/nn/tensorflow/python/keras/utils/__init__.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 857 | 46.666667 | 93 | py |
nlp-architect | nlp-architect-master/nlp_architect/models/intent_extraction.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 13,602 | 35.469169 | 100 | py |
nlp-architect | nlp-architect-master/nlp_architect/models/tagging.py | # ******************************************************************************
# Copyright 2017-2019 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 24,647 | 39.012987 | 99 | py |
nlp-architect | nlp-architect-master/nlp_architect/models/temporal_convolutional_network.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 17,395 | 36.735358 | 99 | py |
nlp-architect | nlp-architect-master/nlp_architect/models/chunker.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 9,885 | 35.88806 | 100 | py |
nlp-architect | nlp-architect-master/nlp_architect/models/most_common_word_sense.py | # ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apa... | 2,100 | 37.907407 | 99 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.