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
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/run_language_modeling.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
34,451
42.776366
165
py
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/run_ner.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
33,949
42.863049
150
py
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/bert_for_re.py
import torch import torch.nn as nn from transformers import BertModel, BertPreTrainedModel, BertConfig class FCLayer(nn.Module): def __init__(self, input_dim, output_dim, dropout_rate=0., use_activation=True): super(FCLayer, self).__init__() self.use_activation = use_activation self.dropou...
3,515
36.806452
143
py
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/utils_re.py
""" From https://github.com/monologg/R-BERT/blob/master/data_loader.py """ import os import csv import copy import json import logging import torch from torch.utils.data import TensorDataset ADDITIONAL_SPECIAL_TOKENS = ["<e1>", "</e1>", "<e2>", "</e2>"] logger = logging.getLogger(__name__) class InputExample(obje...
9,018
34.789683
135
py
ner-rc-russian
ner-rc-russian-master/nn_methods/BERT/bert_for_ner.py
import numpy as np import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from torchcrf import CRF from transformers import ( PreTrainedModel, BertConfig, BertModel, add_start_docstrings ) from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_calla...
13,001
34.818182
145
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/config/Tester.py
# coding:utf-8 import torch import torch.nn as nn from torch.autograd import Variable import torch.optim as optim import os import time import sys import datetime import ctypes import json import numpy as np from sklearn.metrics import roc_auc_score import copy from tqdm import tqdm class Tester(object): def __in...
5,393
34.721854
98
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/config/Trainer.py
# coding:utf-8 import torch import torch.nn as nn from torch.autograd import Variable import torch.optim as optim import os import time import sys import datetime import ctypes import json import numpy as np import copy from tqdm import tqdm class Trainer(object): def __init__(self, model = None, data_loa...
3,413
24.477612
94
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/BaseModule.py
import torch import torch.nn as nn import os import json import numpy as np class BaseModule(nn.Module): def __init__(self): super(BaseModule, self).__init__() self.zero_const = nn.Parameter(torch.Tensor([0])) self.zero_const.requires_grad = False self.pi_const = nn.Parameter(torch.Tensor([3.1415926535897932...
1,501
26.309091
70
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/loss/SigmoidLoss.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from .Loss import Loss class SigmoidLoss(Loss): def __init__(self, adv_temperature = None): super(SigmoidLoss, self).__init__() self.criterion = nn.LogSigmoid() if adv_temperature != None: self.adv_temperature = nn.Paramet...
951
30.733333
125
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/loss/MarginLoss.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import numpy as np from .Loss import Loss class MarginLoss(Loss): def __init__(self, adv_temperature = None, margin = 6.0): super(MarginLoss, self).__init__() self.margin = nn.Parameter(torch.Tensor([margin])) ...
1,046
30.727273
117
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/loss/SoftplusLoss.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from .Loss import Loss class SoftplusLoss(Loss): def __init__(self, adv_temperature = None): super(SoftplusLoss, self).__init__() self.criterion = nn.Softplus() if adv_temperature != None: self.adv_temperature = nn.Paramet...
954
29.806452
124
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/DistMult.py
import torch import torch.nn as nn from .Model import Model class DistMult(Model): def __init__(self, ent_tot, rel_tot, dim = 100, margin = None, epsilon = None): super(DistMult, self).__init__(ent_tot, rel_tot) self.dim = dim self.margin = margin self.epsilon = epsilon self.ent_embeddings = nn.Embedding(...
2,140
28.328767
96
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/ComplEx.py
import torch import torch.nn as nn from .Model import Model class ComplEx(Model): def __init__(self, ent_tot, rel_tot, dim = 100): super(ComplEx, self).__init__(ent_tot, rel_tot) self.dim = dim self.ent_re_embeddings = nn.Embedding(self.ent_tot, self.dim) self.ent_im_embeddings = n...
2,305
36.193548
69
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/RotatE.py
import torch import torch.autograd as autograd import torch.nn as nn from .Model import Model class RotatE(Model): def __init__(self, ent_tot, rel_tot, dim = 100, margin = 6.0, epsilon = 2.0): super(RotatE, self).__init__(ent_tot, rel_tot) self.margin = margin self.epsilon = epsilon self.dim_e = dim * 2 ...
3,228
30.349515
98
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/SimplE.py
import torch import torch.nn as nn from .Model import Model class SimplE(Model): def __init__(self, ent_tot, rel_tot, dim = 100): super(SimplE, self).__init__(ent_tot, rel_tot) self.dim = dim self.ent_embeddings = nn.Embedding(self.ent_tot, self.dim) self.rel_embeddings = nn.Embed...
1,961
34.672727
107
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/Analogy.py
import torch import torch.nn as nn import torch.nn.functional as F from .Model import Model class Analogy(Model): def __init__(self, ent_tot, rel_tot, dim = 100): super(Analogy, self).__init__(ent_tot, rel_tot) self.dim = dim self.ent_re_embeddings = nn.Embedding(self.ent_tot, self.dim) self.ent_im_embeddin...
2,605
33.746667
65
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/HolE.py
#coding:utf-8 import numpy as np import tensorflow as tf from .Model import Model class HolE(Model): def __init__(self, ent_tot, rel_tot, dim = 100): super(HolE, self).__init__(ent_tot, rel_tot) self.dim = dim self.ent_embeddings = nn.Embedding(self.ent_tot, self.dim) self.rel_embeddings = nn.Embedding(self...
4,093
37.622642
117
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/TransR.py
import torch import torch.nn as nn import torch.nn.functional as F from .Model import Model class TransR(Model): def __init__(self, ent_tot, rel_tot, dim_e = 100, dim_r = 100, p_norm = 1, norm_flag = True, rand_init = False, margin = None): super(TransR, self).__init__(ent_tot, rel_tot) self.dim_e = dim_e s...
3,151
29.601942
128
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/RESCAL.py
import torch import torch.nn as nn from .Model import Model class RESCAL(Model): def __init__(self, ent_tot, rel_tot, dim = 100): super(RESCAL, self).__init__(ent_tot, rel_tot) self.dim = dim self.ent_embeddings = nn.Embedding(self.ent_tot, self.dim) self.rel_matrices = nn.Embedding(self.rel_tot, self.dim *...
1,293
27.130435
76
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/TransE.py
import torch import torch.nn as nn import torch.nn.functional as F from .Model import Model class TransE(Model): def __init__(self, ent_tot, rel_tot, dim = 100, p_norm = 1, norm_flag = True, margin = None, epsilon = None): super(TransE, self).__init__(ent_tot, rel_tot) self.dim = dim self.margin = margin ...
2,594
26.606383
110
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/Model.py
import torch import torch.nn as nn from ..BaseModule import BaseModule class Model(BaseModule): def __init__(self, ent_tot, rel_tot): super(Model, self).__init__() self.ent_tot = ent_tot self.rel_tot = rel_tot def forward(self): raise NotImplementedError def predict(self): raise NotImplementedError
318
17.764706
38
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/TransH.py
import torch import torch.nn as nn import torch.nn.functional as F from .Model import Model class TransH(Model): def __init__(self, ent_tot, rel_tot, dim = 100, p_norm = 1, norm_flag = True, margin = None, epsilon = None): super(TransH, self).__init__(ent_tot, rel_tot) self.dim = dim self.margin = margin ...
3,373
28.33913
110
py
ner-rc-russian
ner-rc-russian-master/nn_methods/OpenKE/openke/module/model/TransD.py
import torch import torch.nn as nn import torch.nn.functional as F from .Model import Model class TransD(Model): def __init__(self, ent_tot, rel_tot, dim_e = 100, dim_r = 100, p_norm = 1, norm_flag = True, margin = None, epsilon = None): super(TransD, self).__init__(ent_tot, rel_tot) self.dim_e = dim_e self...
4,867
30.406452
125
py
ner-rc-russian
ner-rc-russian-master/nn_methods/Vocab/sp_for_bert.py
import os import sys import json import nltk import random import sentencepiece as spm from tensorflow.keras.utils import Progbar regex_tokenizer = nltk.RegexpTokenizer("\w+") def normalize_text(text): # lowercase text text = str(text).lower() # remove non-UTF text = text.encode("utf-8", "ignore").decode() ...
2,446
25.89011
82
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/example.py
import torch from knowledge_bert import BertTokenizer, BertModel, BertForMaskedLM # OPTIONAL: if you want to have more information on what's happening, activate the logger as follows import logging logging.basicConfig(level=logging.INFO) # Load pre-trained model tokenizer (vocabulary) tokenizer = BertTokenizer.from_p...
3,651
28.691057
100
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/eval_fewrel.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
22,334
40.747664
139
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/run_fewrel.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
23,787
41.861261
130
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/eval_typing.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
22,976
38.890625
129
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/run_ner.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
24,597
41.704861
130
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/run_tacred.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
24,597
41.704861
130
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/iterators.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import math impo...
8,280
32.526316
93
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/run_pretrain.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
20,008
45.641026
263
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/jupyter_pretrain.py
"""BERT finetuning runner.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import csv import os import logging import argparse import random from tqdm import tqdm, trange import numpy as np import torch from torch.utils.data import TensorDataset, DataLo...
15,692
41.760218
238
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/create_instances.py
import random import numpy as np import collections import torch import tensorflow as tf import indexed_dataset flags = tf.flags FLAGS = flags.FLAGS flags.DEFINE_string("input_file_prefix", None, "Input text/entity file.") flags.DEFINE_string( "output_file", None, "Output TF exampl...
13,602
38.428986
140
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/indexed_dataset.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import os import struct import nu...
6,299
29.288462
84
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/eval_figer.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
23,270
38.984536
129
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/eval_tacred.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
22,448
40.726766
139
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/run_typing.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
23,637
40.181185
130
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/knowledge_bert/optimization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # # 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/LICENS...
6,803
40.742331
116
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/knowledge_bert/__main__.py
# coding: utf8 def main(): import sys try: from .convert_tf_checkpoint_to_pytorch import convert_tf_checkpoint_to_pytorch except ModuleNotFoundError: print("pytorch_pretrained_bert can only be used from the commandline to convert TensorFlow models in PyTorch, " "In that case, i...
932
39.565217
137
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/knowledge_bert/modeling.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HugginFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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...
67,057
48.525849
158
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/knowledge_bert/file_utils.py
""" Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp Copyright by the AllenNLP authors. """ import os import logging import shutil import tempfile import json from urllib.parse import urlparse from pathlib import Path from typing ...
8,021
32.425
98
py
ner-rc-russian
ner-rc-russian-master/nn_methods/ERNIE/code/knowledge_bert/convert_tf_checkpoint_to_pytorch.py
# coding=utf-8 # Copyright 2018 The HugginFace Inc. team. # # 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 ...
4,463
38.504425
101
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/main.py
# -*- coding: utf-8 -*- """ Created on 2019/8/4 上午9:53 @author: mick.yi 入口类 """ import argparse import os import re import cv2 import numpy as np import torch from skimage import io from torch import nn from torchvision import models # from MultipleFeatureswithattentionmno import MultipleFeatures from reid import R...
6,258
30.452261
148
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/test.py
from __future__ import print_function, division import torch import argparse from torch.autograd import Variable from torchvision import datasets, models, transforms import os import scipy.io import math from MultipleFeatureswithoutattention import MultipleFeatures parser = argparse.ArgumentParser(description='testin...
5,113
36.881481
186
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/demo_retinanet.py
# -*- coding: utf-8 -*- """ @File : demo_retinanet.py @Time : 2020/5/16 下午9:59 @Author : yizuotian @Description : """ import argparse import multiprocessing as mp import os import cv2 import detectron2.data.transforms as T import numpy as np import torch from detectron2.checkpoint import DetectionCheckp...
5,695
29.623656
103
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/preparecuhkl.py
import os from shutil import copyfile # You only need to change this line to your dataset download path for each dataset download_path = '........./cuhk03-np/labeled' if not os.path.isdir(download_path): print('please change the download_path') # os.mkdir('model') save_path = download_path + '/pytorch' if not os...
3,732
33.247706
85
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/evaluate.py
import scipy.io import torch import numpy as np #import time import os ####################################################################### # Evaluate def evaluate(qf,ql,qc,gf,gl,gc): query = qf score = np.dot(gf,query) # predict index index = np.argsort(score) #from small to large index = inde...
3,425
30.722222
118
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/evaluate_gpu.py
import scipy.io import torch import numpy as np #import time import os ####################################################################### # Evaluate def evaluate(qf,ql,qc,gf,gl,gc): query = qf.view(-1,1) # print(query.shape) score = torch.mm(gf,query) score = score.squeeze(1).cpu() score = sco...
3,730
31.163793
118
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/triplet_loss.py
# encoding: utf-8 """ @author: liaoxingyu @contact: sherlockliao01@gmail.com """ import torch from torch import nn def normalize(x, axis=-1): """Normalizing to unit length along the specified dimension. Args: x: pytorch Variable Returns: x: pytorch Variable, same shape as input """ x ...
5,382
35.619048
95
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/demo.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import argparse import multiprocessing as mp import os import cv2 import detectron2.data.transforms as T import numpy as np import torch from detectron2.checkpoint import DetectionCheckpointer from detectron2.config import get_cfg from detectron2.d...
6,925
27.979079
100
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/cbam.py
import torch import torch.nn as nn import math import torch.utils.model_zoo as model_zoo __all__ = ['ResNet', 'resnet18_cbam', 'resnet34_cbam', 'resnet50_cbam', 'resnet101_cbam', 'resnet152_cbam'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': ...
8,965
31.251799
89
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/guided_back_propagation.py
# -*- coding: utf-8 -*- """ Created on 2019/8/4 上午9:45 @author: mick.yi """ import torch from torch import nn import numpy as np class GuidedBackPropagation(object): def __init__(self, net): self.net = net for (name, module) in self.net.named_modules(): if isinstance(module, nn.ReLU...
1,111
21.693878
65
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/samplers.py
from __future__ import absolute_import from __future__ import division from collections import defaultdict import numpy as np import copy import random import torch from torch.utils.data.sampler import Sampler class RandomIdentitySampler(Sampler): """ Randomly sample N identities, then for each identity, ...
2,435
33.309859
84
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/evaluate_rerank.py
import scipy.io import torch import numpy as np import time from re_ranking import re_ranking ####################################################################### # Evaluate def evaluate(score,ql,qc,gl,gc): index = np.argsort(score) #from small to large #index = index[::-1] # good index query_index...
2,735
31.188235
98
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/CBAM.py
import torch import torch.nn as nn import math import torch.utils.model_zoo as model_zoo __all__ = ['ResNet', 'resnet18_cbam', 'resnet34_cbam', 'resnet50_cbam', 'resnet101_cbam', 'resnet152_cbam'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth', 'resnet34': ...
8,998
31.139286
89
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/train.py
from __future__ import print_function, division import torch import torch.optim as optim from torchvision import datasets, transforms import matplotlib matplotlib.use('agg') import time import os import argparse #you can change here from MultipleFeatureswithoutattention import MultipleFeatures import matplot...
15,240
46.777429
250
py
MutipleFeature-for-PRID
MutipleFeature-for-PRID-master/MultipleFeatureswithoutattention.py
import torch import torch.nn as nn from torch.nn import init from torchvision import models ##################################################################### def weights_init_kaiming(m): classname = m.__class__.__name__ if classname.find('Conv2d') != -1: init.kaiming_normal_(m.weight.data, a=0, mod...
8,797
41.298077
85
py
alda
alda-master/benchmarks/rules/PA/download.py
""" download repos used in PA experiments """ import os,sys def main(): def download(repo): print('downloading ',repo) os.system(f'git clone --depth=1 --branch {repo_tag[repo]} {repo_url[repo]}') #os.system(f'git clone {repo_map[repo]}') #os.system(f'cd {repo} && git checkout {repo...
1,269
26.608696
84
py
alda
alda-master/benchmarks/rules/PA/io_time.py
# measure time to read facts from .P and write them to pickle files import os, time, pickle, collections, re, statistics def main(): datasets="blender django matplotlib numpy pandas pytorch scikit-learn scipy sympy".split(' ') cputime0 = {} cputime1 = {} cputime2 = {} cputime3 = {} classdefsz...
2,151
34.278689
252
py
alda
alda-master/benchmarks/rules/PA/data_prep/download.py
# download github repos used in PA experiments import os,sys def main(): def download(repo): print('downloading ',repo) os.system(f'git clone --depth=1 --branch {repo_tag[repo]} {repo_url[repo]}') #os.system(f'git clone {repo_map[repo]}') #os.system(f'cd {repo} && git checkout {rep...
1,270
27.244444
84
py
alda
alda-master/benchmarks/rules/PA/data_prep/pyast_views.py
""" generate pickled facts for the input module: 'folder or file, and a user readable version by file. """ import ast,os,sys,shutil,pickle from collections.abc import Collection from pprint import pprint class Generator: def __init__(self): self.reset() self.pickleFolder = '_state' self.t...
9,998
40.83682
209
py
LatentOps
LatentOps-main/code/train_ddpm_latent.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
37,591
47.884265
147
py
LatentOps
LatentOps-main/code/my_transformers.py
import copy from abc import ABC import torch from torch import nn from torch.nn import CrossEntropyLoss # from sentence_transformers import SentenceTransformer from transformers.models.bert.modeling_bert import BertModel, BertPooler, BertLayer from transformers.models.deberta.modeling_deberta import DebertaModel, Cont...
39,200
43.90378
126
py
LatentOps
LatentOps-main/code/test_SBM_sde.py
import torch import argparse import torch.nn as nn import torch.nn.functional as F import numpy as np import functools import os from my_transformers import * from transformers import AutoTokenizer, AdamW import copy from examples.big_ae.modules import VAE,sample_sequence_conditional, DDPM, LinearModel import logging f...
16,316
38.129496
121
py
LatentOps
LatentOps-main/code/examples/big_ae/run_latent_generation.py
#!/usr/bin/env python3 # coding=utf-8 # Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in c...
35,004
46.17655
194
py
LatentOps
LatentOps-main/code/examples/big_ae/ddpm_conditional.py
''' This script does conditional image generation on MNIST, using a diffusion model This code is modified from, https://github.com/cloneofsimo/minDiffusion Diffusion model is based on DDPM, https://arxiv.org/abs/2006.11239 The conditioning idea is taken from 'Classifier-Free Diffusion Guidance', https://arxiv.org/ab...
15,248
36.83871
176
py
LatentOps
LatentOps-main/code/examples/big_ae/ppvae_training.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
57,651
50.109929
165
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling_word.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
27,709
47.024263
153
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_tst_my.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
31,929
49.362776
152
py
LatentOps
LatentOps-main/code/examples/big_ae/conditional_generation.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
24,466
46.787109
151
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_vae_training.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
59,057
52.349593
191
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_tst_content.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
32,654
50.915739
153
py
LatentOps
LatentOps-main/code/examples/big_ae/utils.py
import json import os import pickle import random import subprocess import numpy as np import torch import torch.nn.init as init from torch import nn from torch.nn.utils.rnn import pad_sequence from torch.utils.data import DataLoader, Dataset, Sampler from torch.utils.data.distributed import DistributedSampler from tq...
61,018
39.544186
155
py
LatentOps
LatentOps-main/code/examples/big_ae/fgim_tst.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
34,465
49.985207
153
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling_wor.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
27,645
46.747841
153
py
LatentOps
LatentOps-main/code/examples/big_ae/train_simcse.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
47,878
50.372318
165
py
LatentOps
LatentOps-main/code/examples/big_ae/train_ddpm_latent.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
34,122
47.886819
147
py
LatentOps
LatentOps-main/code/examples/big_ae/minddpm.py
""" Extremely Minimalistic Implementation of DDPM https://arxiv.org/abs/2006.11239 Everything is self contained. (Except for pytorch and torchvision... of course) run it with `python superminddpm.py` """ from typing import Dict, Tuple from tqdm import tqdm import torch import torch.nn as nn from torch.utils.data i...
6,612
29.901869
102
py
LatentOps
LatentOps-main/code/examples/big_ae/my_transformers.py
import copy from abc import ABC import torch from torch import nn from torch.nn import CrossEntropyLoss # from sentence_transformers import SentenceTransformer from transformers.models.bert.modeling_bert import BertModel, BertPooler, BertLayer from transformers.models.deberta.modeling_deberta import DebertaModel, Cont...
39,200
43.90378
126
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling_transfer.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
30,852
47.511006
167
py
LatentOps
LatentOps-main/code/examples/big_ae/test_SBM_sde.py
import torch import argparse import torch.nn as nn import torch.nn.functional as F import numpy as np import functools import os from my_transformers import * from transformers import AutoTokenizer, AdamW import copy from examples.big_ae.modules import VAE,sample_sequence_conditional, DDPM, LinearModel import logging f...
16,359
38.045346
121
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_daae_training.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
46,830
52.952765
283
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_vae_training_fixdec.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
67,117
51.069822
200
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
29,056
48.926117
153
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_vae_training_fix.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
59,551
50.604853
283
py
LatentOps
LatentOps-main/code/examples/big_ae/train_cls_gan.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
58,836
51.160461
165
py
LatentOps
LatentOps-main/code/examples/big_ae/train_cls_latent.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
61,603
49.577997
165
py
LatentOps
LatentOps-main/code/examples/big_ae/ddpm.py
''' This script does conditional image generation on MNIST, using a diffusion model This code is modified from, https://github.com/cloneofsimo/minDiffusion Diffusion model is based on DDPM, https://arxiv.org/abs/2006.11239 The conditioning idea is taken from 'Classifier-Free Diffusion Guidance', https://arxiv.org/ab...
15,249
36.841191
176
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling_my.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
28,235
45.06199
151
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_tst.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
32,824
50.611635
153
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_lace_training.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
56,930
51.909851
165
py
LatentOps
LatentOps-main/code/examples/big_ae/utils_eval.py
import numpy as np import os, sys import torch from torch import nn, optim import subprocess from tqdm import tqdm, trange from torch.utils.data import DataLoader, Dataset, Sampler, SequentialSampler, RandomSampler from torch.nn.utils.rnn import pad_sequence import json import pdb import torch.nn.init as init import...
61,443
39.583884
164
py
LatentOps
LatentOps-main/code/examples/big_ae/run_lm_content_training.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
66,089
50.552262
165
py
LatentOps
LatentOps-main/code/examples/big_ae/lace_sampling_find_weight.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
21,208
54.231771
151
py
LatentOps
LatentOps-main/code/examples/big_ae/utils_simcse.py
import numpy as np import os, sys import torch from torch import nn, optim import subprocess from tqdm import tqdm, trange from torch.utils.data import DataLoader, Dataset, Sampler, SequentialSampler, RandomSampler from torch.nn.utils.rnn import pad_sequence import json import pdb import torch.nn.init as init import...
60,732
39.354153
145
py
LatentOps
LatentOps-main/code/examples/big_ae/modules/ctrl_gen.py
import math import torch import torch.nn as nn from .utils import log_sum_exp import pdb import sys sys.path.append('../../') from pytorch_transformers.modeling_bert import BertEmbeddings import torch.nn.functional as F class Ctrl_Gen(nn.Module): def __init__(self, encoder, decoder, tokenizer_encoder, tokenizer_d...
19,226
50.685484
159
py
LatentOps
LatentOps-main/code/examples/big_ae/modules/cara.py
import math import torch import torch.nn as nn from .utils import log_sum_exp import pdb import sys sys.path.append('../../') from pytorch_transformers.modeling_bert import BertEmbeddings import torch.nn.functional as F class CARA(nn.Module): def __init__(self, encoder, decoder, tokenizer_encoder, tokenizer_decod...
19,558
51.157333
159
py
LatentOps
LatentOps-main/code/examples/big_ae/modules/utils.py
import torch def safe_log(z): return torch.log(z + 1e-7) def log_sum_exp(value, dim=None, keepdim=False): """Numerically stable implementation of the operation value.exp().sum(dim, keepdim).log() """ if dim is not None: m, _ = torch.max(value, dim=dim, keepdim=True) value0 = value ...
1,162
28.075
84
py
LatentOps
LatentOps-main/code/examples/big_ae/modules/vae.py
import math import torch import torch.nn as nn from .utils import log_sum_exp import pdb import numpy as np import logging from typing import Dict, Tuple logger = logging.getLogger(__name__) def reparameterize(mu, logvar, nsamples=1): """sample from posterior Gaussian family Args: mu: Tensor ...
61,553
37.208566
159
py