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 |
|---|---|---|---|---|---|---|
dl-4-tsc | dl-4-tsc-master/classifiers/resnet.py | # resnet model
# when tuning start with learning rate->mini_batch_size ->
# momentum-> #hidden_units -> # learning_rate_decay -> #layers
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
import matplotlib
from utils.utils import save_test_duration
matplotlib.use('agg')
import ... | 6,882 | 39.488235 | 115 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/cnn.py | # FCN model
# when tuning start with learning rate->mini_batch_size ->
# momentum-> #hidden_units -> # learning_rate_decay -> #layers
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
from utils.utils import save_logs
from utils.utils import calculate_metrics
class Classifier_CNN... | 3,438 | 34.822917 | 110 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/mlp.py | # MLP model
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from utils.utils import save_logs
from utils.utils import calculate_metrics
class Classifier_MLP:
def __init__(self, output_directory, input... | 3,179 | 31.121212 | 101 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/encoder.py | # Our proposed model CNN + LSTM
import tensorflow.keras as keras
import tensorflow as tf
import tensorflow_addons as tfa
import numpy as np
import time
from utils.utils import save_logs
from utils.utils import calculate_metrics
class Classifier_ENCODER:
def __init__(self, output_directory, input_shape, nb_classe... | 4,505 | 40.722222 | 109 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/mcnn.py | # MCNN model
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
from utils.utils import calculate_metrics
from utils.utils import create_directory
class Classifier_MCNN:
def __init__(self, output_directory, verbose, build=True):
self.output_directory = output_directo... | 20,516 | 39.072266 | 112 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/tlenet.py | # t-leNet model: t-leNet + WW
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
from utils.utils import save_logs_t_leNet as save_logs
from utils.utils import calculate_metrics
class Classifier_TLENET:
def __init__(self, output_directory, verbose,build=True):
s... | 10,228 | 35.402135 | 137 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/mcdcnn.py | # FCN model
# when tuning start with learning rate->mini_batch_size ->
# momentum-> #hidden_units -> # learning_rate_decay -> #layers
import tensorflow.keras as keras
import numpy as np
from sklearn.model_selection import train_test_split
import time
import tensorflow as tf
from utils.utils import save_logs
from utils.... | 4,451 | 34.055118 | 121 | py |
dl-4-tsc | dl-4-tsc-master/utils/utils.py | from builtins import print
import numpy as np
import pandas as pd
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
matplotlib.rcParams['font.family'] = 'sans-serif'
matplotlib.rcParams['font.sans-serif'] = 'Arial'
import os
import operator
import utils
from utils.constants import UNIVARIATE_D... | 24,330 | 35.314925 | 120 | py |
habitat-sim | habitat-sim-main/examples/instance_segmentation/engine.py | # Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import collections
import math
import sys
import time
import torch
import torchvision.models.detection.mask_rcnn
from examples.instance_... | 5,339 | 33.230769 | 88 | py |
habitat-sim | habitat-sim-main/examples/instance_segmentation/common.py | # Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import collections
import math
import random
import numpy as np
import torch
def create_mask_filter(labels, extractor):
instance_id... | 4,656 | 32.264286 | 88 | py |
habitat-sim | habitat-sim-main/tests/test_profiling_utils.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import importlib
import os
from io import StringIO
from unittest.mock import patch
import pytest
from habitat_s... | 4,633 | 34.646154 | 134 | py |
habitat-sim | habitat-sim-main/tests/test_sensors.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import importlib.util
import itertools
import json
from os import path as osp
from typing import Any, Dict
import ... | 12,610 | 33.456284 | 88 | py |
habitat-sim | habitat-sim-main/tests/test_data_extraction.py | # Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import pytest
# skip all tests if torch not installed
torch = pytest.importorskip("torch")
from torch import nn as nn
... | 2,819 | 30.685393 | 84 | py |
habitat-sim | habitat-sim-main/src_python/habitat_sim/simulator.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import time
from collections import OrderedDict
from collections.abc import MutableMapping
from typing import Any,... | 28,910 | 36.401035 | 117 | py |
habitat-sim | habitat-sim-main/src_python/habitat_sim/utils/profiling_utils.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
r"""Helper functions for profiling. Profilers like Nvidia Nsight can capture the
time spent in annotated ranges.
E... | 5,954 | 32.644068 | 80 | py |
habitat-sim | habitat-sim-main/src_python/habitat_sim/sensors/noise_models/no_noise_model.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Union
import attr
import numpy as np
from numpy import ndarray
from habitat_sim.registry impo... | 1,015 | 25.736842 | 80 | py |
habitat-sim | habitat-sim-main/src_python/habitat_sim/sensors/noise_models/sensor_noise_model.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Optional, Union
import attr
from numpy import ndarray
try:
from torch import T... | 1,364 | 26.3 | 82 | py |
habitat-sim | habitat-sim-main/src_python/habitat_sim/sensors/noise_models/redwood_depth_noise_model.py | #!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from os import path as osp
from typing import Union
import attr
import numba
import numpy as np
from numpy import... | 4,881 | 31.765101 | 101 | py |
FinQA | FinQA-main/code/generator/Test.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main script
"""
from tqdm import tqdm
import json
import os
from datetime import datetime
import time
import logging
from utils import *
from config import parameters as conf
from torch import nn
import torch
import torch.optim as optim
from Model_new import Bert_mode... | 6,866 | 34.95288 | 126 | py |
FinQA | FinQA-main/code/generator/utils.py | import time
import os
import sys
import shutil
import io
import subprocess
import re
import zipfile
import json
import copy
import torch
import random
import collections
import math
import numpy as np
from tqdm import tqdm
import torch.nn.functional as F
from config import parameters as conf
from transformers import Be... | 25,374 | 28.747948 | 119 | py |
FinQA | FinQA-main/code/generator/Main.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main script
"""
from tqdm import tqdm
import json
import os
from datetime import datetime
import time
import logging
from utils import *
from config import parameters as conf
from torch import nn
import torch
import torch.optim as optim
from Model_new import Bert_mode... | 11,036 | 36.927835 | 129 | py |
FinQA | FinQA-main/code/generator/Model_new.py | import torch
from torch import nn
import torch.optim as optim
import torch.nn.functional as F
import math
import numpy as np
from config import parameters as conf
if conf.pretrained_model == "bert":
from transformers import BertModel
elif conf.pretrained_model == "roberta":
from transformers import RobertaMode... | 13,570 | 41.01548 | 119 | py |
FinQA | FinQA-main/code/retriever/Test.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main script
"""
from tqdm import tqdm
import json
import os
from datetime import datetime
import time
import logging
from utils import *
from config import parameters as conf
from torch import nn
import torch
import torch.optim as optim
from Model import Bert_model
i... | 4,590 | 31.104895 | 106 | py |
FinQA | FinQA-main/code/retriever/utils.py | import time
import os
import sys
import shutil
import io
import subprocess
import re
import zipfile
import json
import copy
import torch
import random
import collections
import math
import numpy as np
import torch.nn.functional as F
from config import parameters as conf
from tqdm import tqdm
from transformers import Be... | 13,173 | 26.106996 | 110 | py |
FinQA | FinQA-main/code/retriever/Main.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main script
"""
from tqdm import tqdm
import json
import os
from datetime import datetime
import time
import logging
from utils import *
from config import parameters as conf
from torch import nn
import torch
import torch.optim as optim
from Model import Bert_model
i... | 8,275 | 34.519313 | 106 | py |
FinQA | FinQA-main/code/retriever/Model.py | import torch
from torch import nn
import torch.optim as optim
import torch.nn.functional as F
import math
import numpy as np
from config import parameters as conf
if conf.pretrained_model == "bert":
from transformers import BertModel
elif conf.pretrained_model == "roberta":
from transformers import RobertaMode... | 1,504 | 29.1 | 87 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/baselines.py | from setformer import *
from torch_geometric.nn import GCNConv, global_add_pool
def build_mlp(hidden_dim, out_dim, num_hidden_layers=1, normalize_input=True):
net = []
if normalize_input:
net.append(LayerNorm(hidden_dim))
for _ in range(num_hidden_layers):
net.append(Linear(hidden_dim, hidden_dim))
net.appen... | 7,897 | 50.620915 | 272 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/base_model.py | import os
import itertools
import numpy as np
from sklearn.metrics import r2_score, mean_absolute_error, mean_squared_error
from scipy import stats
import torch
import torch.nn as nn
import logging
import time
import datetime
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt
from tqdm import tqdm
from fu... | 11,199 | 35.601307 | 151 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/cpt.py | import os
import itertools
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Sequential, Linear, LeakyReLU, Dropout, LayerNorm
from torch_scatter import scatter_add
from torch_geometric.utils import softmax
from transformer import TransformerEncoder, TransformerDecoder, GraphMLP, G... | 45,416 | 52.243845 | 308 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/utils.py | import torch
import numpy as np
import torch
from torch_geometric.data import Data, Batch
dataset_id = {
't_schan': 0,
't_tchan': 1,
'ttbar': 2,
'ttH': 3,
'ttH_applied': 3,
'ttyy_had': 4,
'ttyy_lep': 5,
'ttt': 6,
'tttt': 7,
'ttW': 8,
'tHjb': 9,
'ttH_odd': 10,
}
def to_torch(data, pad_y_up_to, drop_one_hot... | 11,413 | 36.422951 | 169 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/dataset.py | from torch_geometric.data import Dataset
from torch_geometric.data import Data, Batch
from torch.utils.data import IterableDataset
from functools import partial
from tqdm import tqdm
import lmdb
import gzip
import json
import io
import pickle as pkl
from pathlib import Path
import gc
tqdm = partial(tqdm, position=0, le... | 3,030 | 31.244681 | 129 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/transformer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import Sequential, Linear, LeakyReLU, Dropout, LayerNorm, Identity, Sigmoid
from torch_geometric.nn import GCNConv, global_add_pool, Set2Set, GlobalAttention
from typing import Optional
import torch
from torch import Tensor
from torch_scat... | 18,596 | 41.85023 | 261 | py |
Covariant-Particle-Transformer | Covariant-Particle-Transformer-master/lamb.py | # From https://github.com/cybertronai/pytorch-lamb/blob/master/pytorch_lamb/lamb.py
import math
import torch
from torch.optim import Optimizer
class Lamb(Optimizer):
r"""Implements Lamb algorithm.
It has been proposed in `Large Batch Optimization for Deep Learning: Training BERT in 76 minutes`_.
Argumen... | 4,455 | 40.259259 | 109 | py |
qubovert | qubovert-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 5,591 | 27.530612 | 79 | py |
PCL | PCL-master/voc.py | from __future__ import print_function, division, absolute_import
import csv
import os
import os.path
import tarfile
from six.moves.urllib.parse import urlparse
import numpy as np
import torch
import torch.utils.data as data
from PIL import Image
import random
from tqdm import tqdm
from six.moves.urllib.request import... | 10,839 | 32.76947 | 102 | py |
PCL | PCL-master/main_pcl.py | import argparse
import builtins
import math
import os
import random
import shutil
import time
import warnings
from tqdm import tqdm
import numpy as np
import faiss
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import... | 22,501 | 39.617329 | 134 | py |
PCL | PCL-master/eval_cls_imagenet.py | import argparse
import builtins
import os
import random
import shutil
import time
import warnings
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.multiprocessing as mp
import torch.utils.data
import torch.... | 19,528 | 38.136273 | 96 | py |
PCL | PCL-master/eval_svm_voc.py | from __future__ import print_function
import os
import sys
import time
import torch
import torch.optim as optim
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
import argparse
import random
import numpy as np
from torchvision import transforms, datasets
import torchvision.models as models
from v... | 8,812 | 34.971429 | 123 | py |
PCL | PCL-master/pcl/builder.py | import torch
import torch.nn as nn
from random import sample
class MoCo(nn.Module):
"""
Build a MoCo model with: a query encoder, a key encoder, and a queue
https://arxiv.org/abs/1911.05722
"""
def __init__(self, base_encoder, dim=128, r=16384, m=0.999, T=0.1, mlp=False):
"""
dim: f... | 7,772 | 35.153488 | 153 | py |
PCL | PCL-master/pcl/loader.py | from PIL import ImageFilter
import random
import torchvision.datasets as datasets
class TwoCropsTransform:
"""Take two random crops of one image as the query and key."""
def __init__(self, base_transform):
self.base_transform = base_transform
def __call__(self, x):
q = self.base_transfor... | 1,016 | 27.25 | 79 | py |
urnn | urnn-master/custom_layers.py | # -*- coding: utf-8 -*-
import numpy as np
from keras import backend as K
from keras import activations, initializations, regularizers
from keras.engine import Layer, InputSpec
from keras.layers import Recurrent, time_distributed_dense
from keras.engine.topology import Layer
import theano
import theano.tensor as T
f... | 30,161 | 40.717842 | 444 | py |
urnn | urnn-master/custom_optimizers.py | from keras import backend as K
from keras.optimizers import Optimizer
from keras.utils.generic_utils import get_from_module
import theano.tensor as T
class RMSprop_and_natGrad(Optimizer):
'''RMSProp optimizer with the capability to do natural gradient steps.
It is recommended to leave the parameters of this ... | 5,540 | 48.035398 | 138 | py |
urnn | urnn-master/mnist.py | #!/usr/bin/python
'''Pixel-by-pixel MNIST using a unitary RNN (uRNN)
'''
from __future__ import print_function
import os,sys,getopt
import yaml
import cPickle
import numpy as np
np.random.seed(314159) # for reproducibility
import keras.callbacks
from keras.datasets import mnist
from keras.models import Sequential
... | 7,683 | 35.245283 | 169 | py |
MSE-AMR | MSE-AMR-main/collect_amr_data.py | from amr.IO import read_raw_amr_data
from datasets import load_dataset
import pandas as pd
import sys
import torch
import tqdm
# device = torch.device('cuda')
# def get_mt_model(lang):
# from transformers import MarianMTModel, MarianTokenizer
# tokenizer = MarianTokenizer.from_pretrained(f"Helsinki-NLP/opus-m... | 5,846 | 35.31677 | 147 | py |
MSE-AMR | MSE-AMR-main/translate.py | from transformers import MarianMTModel, MarianTokenizer
import tqdm
import torch
def get_langs(dataset):
lang_1 = "en"
lang_2 = "en"
if dataset == "STS.input.track1.ar-ar.txt":
lang_1 = "ar"
lang_2 = "ar"
elif dataset == "STS.input.track2.ar-en.txt":
lang_1 = "en"
lang_2... | 3,057 | 31.88172 | 109 | py |
MSE-AMR | MSE-AMR-main/cache_amrs.py | from amr.IO import read_raw_amr_data
import torch
fname="backup/best/ml_transfer-test-pred.txt"
data, snts = read_raw_amr_data(fname,
dereify=True,
remove_wiki=True,
use_pointer_tokens=True,
drop_parentheses=False)
snts = [ x[len("# ::snt"):].strip() for x in open(fname).readlines() if ... | 485 | 26 | 133 | py |
MSE-AMR | MSE-AMR-main/evaluation.py | import sys
import io, os
import numpy as np
import logging
import argparse
from prettytable import PrettyTable
import torch
import transformers
from transformers import AutoModel, AutoTokenizer, AutoConfig, BertModel
from tatoeba import tatoeba
from bucc import bucc_run
import collections
# Set up logger
logging.basic... | 21,487 | 39.69697 | 161 | py |
MSE-AMR | MSE-AMR-main/simcse_to_huggingface.py | """
Convert SimCSE's checkpoints to Huggingface style.
"""
import argparse
import torch
import os
import json
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--path", type=str, help="Path of SimCSE checkpoint folder")
args = parser.parse_args()
print("SimCSE checkpoint -> Hugging... | 1,466 | 29.5625 | 107 | py |
MSE-AMR | MSE-AMR-main/train.py | import logging
import math
import os
import sys
from dataclasses import dataclass, field
from typing import Optional, Union, List, Dict, Tuple
import torch
import collections
import random
from datasets import load_dataset
import transformers
from transformers import (
CONFIG_MAPPING,
MODEL_FOR_MASKED_LM_MAPP... | 27,034 | 39.051852 | 198 | py |
MSE-AMR | MSE-AMR-main/amr/parser.py | from .IO import read_raw_amr_data
import logging
import torch
logging.getLogger("penman").setLevel(logging.WARNING)
class AMRParser:
def __init__(self, fname, dereify=True, remove_wiki=False, use_pointer_tokens=False, drop_parentheses=False):
if fname.endswith(".pt"):
self.sent_to_amr = torch.... | 930 | 39.478261 | 161 | py |
MSE-AMR | MSE-AMR-main/amr/tokenization.py | import torch
import collections
from .IO import AMRTokens
INIT_XLM_ROBERTA = '▁'
INIT_ROBERTA = 'Ġ'
INIT_BERT = ''
def init_amr_vocabulary(tokenizer, INIT=''):
vocab = tokenizer.get_vocab()
tokens = [t for t in AMRTokens.tokens if INIT+t not in vocab]
tokens.sort()
old_enc_size = len(tokenizer)
to... | 2,878 | 42.621212 | 724 | py |
MSE-AMR | MSE-AMR-main/bucc/bucc_run.py | import subprocess
import os
import time
import numpy as np
import torch
from . import mine_bitexts
from . import bucc as bucc_
from collections import OrderedDict
def run(params, batcher):
cwd = os.getcwd()
os.chdir(os.path.join(cwd, "bucc"))
subprocess.run(['/bin/bash', './extract.sh'])
os.chdir(cwd)
... | 3,610 | 34.058252 | 116 | py |
MSE-AMR | MSE-AMR-main/simcse/tool.py | import logging
from tqdm import tqdm
import numpy as np
from numpy import ndarray
import torch
from torch import Tensor, device
import transformers
from transformers import AutoModel, AutoTokenizer
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.preprocessing import normalize
from typing import List... | 10,898 | 40.599237 | 160 | py |
MSE-AMR | MSE-AMR-main/simcse/trainers.py | import collections
import inspect
import math
import sys
import os
import re
import json
import shutil
import time
import warnings
from pathlib import Path
import importlib.util
from packaging import version
from transformers import Trainer
from transformers.modeling_utils import PreTrainedModel
from transformers.train... | 27,835 | 45.239203 | 157 | py |
MSE-AMR | MSE-AMR-main/simcse/models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.distributed as dist
import copy
import transformers
from transformers.models.roberta.modeling_roberta import RobertaPreTrainedModel, RobertaModel, RobertaLMHead
from transformers.models.bert.modeling_bert import BertPreTrainedModel, BertLM... | 23,076 | 36.831148 | 165 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/infersent.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.
#
"""
InferSent models. See https://github.com/facebookresearch/InferSent.
"""
from __future__ import absolute_import, division,... | 2,463 | 31 | 92 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/bow.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.
#
from __future__ import absolute_import, division, unicode_literals
import sys
import io
import numpy as np
import logging
# ... | 3,423 | 29.300885 | 82 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/googleuse.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.
#
from __future__ import absolute_import, division
import os
import sys
import logging
import tensorflow as tf
import tensorflow... | 2,205 | 31.441176 | 86 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/models.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.
#
"""
This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf
"""
import numpy as np
import t... | 9,875 | 36.12782 | 94 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/gensen.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.
#
"""
Clone GenSen repo here: https://github.com/Maluuba/gensen.git
And follow instructions for loading the model used in batcher... | 2,429 | 31.4 | 82 | py |
MSE-AMR | MSE-AMR-main/SentEval/examples/skipthought.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.
#
from __future__ import absolute_import, division, unicode_literals
"""
Example of file for SkipThought in SentEval
"""
import ... | 2,048 | 32.048387 | 97 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/engine.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.
#
'''
Generic sentence evaluation scripts wrapper
'''
from __future__ import absolute_import, division, unicode_literals
from ... | 8,223 | 50.72327 | 139 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/rank.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.
#
'''
Image-Caption Retrieval with COCO dataset
'''
from __future__ import absolute_import, division, unicode_literals
import os... | 4,643 | 41.605505 | 129 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/qam.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.
#
'''
SICK Relatedness and Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io... | 10,452 | 42.920168 | 115 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/snli.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.
#
'''
SNLI - Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import codecs
import os
import io... | 4,577 | 39.157895 | 75 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/utils.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.
#
from __future__ import absolute_import, division, unicode_literals
import numpy as np
import re
import inspect
from torch impo... | 2,713 | 27.270833 | 79 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/cls.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.
#
'''
TREC question-type classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import... | 4,461 | 43.62 | 139 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/pawsx.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.
#
'''
SICK Relatedness and Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io... | 10,501 | 43.12605 | 119 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/binary.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.
#
'''
Binary classifier and corresponding datasets : MR, CR, SUBJ, MPQA
'''
from __future__ import absolute_import, division, uni... | 3,712 | 38.924731 | 79 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/mrpc.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.
#
'''
MRPC : Microsoft Research Paraphrase (detection) Corpus
'''
from __future__ import absolute_import, division, unicode_liter... | 4,202 | 39.028571 | 80 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/probing.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.
#
'''
probing tasks
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
import copy
impo... | 6,786 | 38.459302 | 120 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/sick.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.
#
'''
SICK Relatedness and Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io... | 9,243 | 41.599078 | 80 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/mldoc.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.
#
'''
SST - binary classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
im... | 5,069 | 41.966102 | 156 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/marc.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.
#
'''
SST - binary classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
im... | 4,963 | 41.42735 | 155 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/xnli.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.
#
'''
SICK Relatedness and Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io... | 10,578 | 43.44958 | 119 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/trec.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.
#
'''
TREC question-type classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import... | 3,565 | 38.622222 | 79 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/sst.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.
#
'''
SST - binary classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
im... | 3,946 | 39.690722 | 94 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/tools/relatedness.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.
#
"""
Semantic Relatedness (supervised) with Pytorch
"""
from __future__ import absolute_import, division, unicode_literals
impo... | 4,552 | 32.725926 | 100 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/tools/validation.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.
#
"""
Validation and classification
(train) : inner-kfold classifier
(train, test) : kfold classifier
(train, d... | 11,121 | 41.776923 | 93 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/tools/classifier.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.
#
"""
Pytorch Classifier class in the style of scikit-learn
Classifiers include Logistic Regression and MLP
"""
from __future__ ... | 10,898 | 40.128302 | 126 | py |
MSE-AMR | MSE-AMR-main/SentEval/senteval/tools/ranking.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.
#
"""
Image Annotation/Search for COCO with Pytorch
"""
from __future__ import absolute_import, division, unicode_literals
impor... | 15,275 | 41.433333 | 109 | py |
dhypr | dhypr-main/code/baselines/train.py | from __future__ import division
from __future__ import print_function
import datetime
import json
import logging
import os
import pickle
import time
import numpy as np
import optimizers
import torch
from config import parser
from models.base_models import NCModel, LPModel, SPModel
from utils.data_utils import load_da... | 7,219 | 39.111111 | 113 | py |
dhypr | dhypr-main/code/baselines/models/decoders.py | import manifolds
import torch.nn as nn
import torch.nn.functional as F
import torch
from layers.att_layers import GraphAttentionLayer
from layers.layers import GraphConvolution, Linear
class Decoder(nn.Module):
def __init__(self, c):
super(Decoder, self).__init__()
self.c = c
def decode(self... | 2,764 | 29.384615 | 106 | py |
dhypr | dhypr-main/code/baselines/models/base_models.py | import os
import numpy as np
from sklearn.metrics import roc_auc_score, average_precision_score
import torch
import torch.nn as nn
import torch.nn.functional as F
from layers.layers import FermiDiracDecoder
import layers.hyp_layers as hyp_layers
import manifolds
import models.encoders as encoders
from models.decoders ... | 5,750 | 34.94375 | 112 | py |
dhypr | dhypr-main/code/baselines/models/encoders.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import manifolds
from layers.att_layers import GraphAttentionLayer
import layers.hyp_layers as hyp_layers
from layers.layers import GraphConvolution, Linear, get_dim_act
import utils.math_utils as pmath
import pdb
class Encoder(nn.... | 5,789 | 35.878981 | 113 | py |
dhypr | dhypr-main/code/baselines/layers/hyp_layers.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
from layers.att_layers import DenseAtt, SpAttn
def get_dim_act_curv(args):
if not args.act:
act = lambda x: x
... | 4,755 | 33.215827 | 103 | py |
dhypr | dhypr-main/code/baselines/layers/att_layers.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import pdb
class DenseAtt(nn.Module):
def __init__(self, in_features, dropout, act):
super(DenseAtt, self).__init__()
self.dropout = dropout
self.linear = nn.Linear(2 * in_features, 1, bias=True)
... | 7,046 | 33.714286 | 109 | py |
dhypr | dhypr-main/code/baselines/layers/layers.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.module import Module
from torch.nn.parameter import Parameter
import pdb
def get_dim_act(args):
if not args.act:
act = lambda x: x
else:
act = getattr(F, args.act)
acts = [act] * (args.num... | 2,050 | 27.09589 | 74 | py |
dhypr | dhypr-main/code/baselines/optimizers/radam.py | import torch.optim
from manifolds import Euclidean, ManifoldParameter
_default_manifold = Euclidean()
class OptimMixin(object):
def __init__(self, *args, stabilize=None, **kwargs):
self._stabilize = stabilize
super().__init__(*args, **kwargs)
def stabilize_group(self, group):
pass
... | 4,215 | 37.327273 | 103 | py |
dhypr | dhypr-main/code/baselines/optimizers/__init__.py | from torch.optim import Adam
from .radam import RiemannianAdam
| 63 | 20.333333 | 33 | py |
dhypr | dhypr-main/code/baselines/utils/data_utils.py | import os
import pickle as pkl
import sys
import networkx as nx
import numpy as np
import scipy.sparse as sp
import torch
import pdb
import random
import pickle
def load_graph(filepath):
G = nx.read_edgelist(os.path.join(filepath, 'train_edges.txt'), delimiter='\t', create_using=nx.DiGraph())
adj = nx.adjace... | 11,323 | 34.3875 | 117 | py |
dhypr | dhypr-main/code/baselines/utils/train_utils.py | import os
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn.modules.loss
def format_metrics(metrics, split):
return " ".join(
["{}_{}: {:.4f}".format(split, metric_name, metric_val) for metric_name, metric_val in metrics.items()])
def get_dir_name(models_dir):
if no... | 2,256 | 30.788732 | 116 | py |
dhypr | dhypr-main/code/baselines/utils/math_utils.py | import torch
def cosh(x, clamp=15):
return x.clamp(-clamp, clamp).cosh()
def sinh(x, clamp=15):
return x.clamp(-clamp, clamp).sinh()
def tanh(x, clamp=15):
return x.clamp(-clamp, clamp).tanh()
def arcosh(x):
return Arcosh.apply(x)
def arsinh(x):
return Arsinh.apply(x)
def artanh(x):
... | 1,515 | 21.294118 | 83 | py |
dhypr | dhypr-main/code/baselines/manifolds/base.py | from torch.nn import Parameter
class Manifold(object):
def __init__(self):
super().__init__()
self.eps = 10e-8
def sqdist(self, p1, p2, c):
raise NotImplementedError
def egrad2rgrad(self, p, dp, c):
raise NotImplementedError
def proj(self, p, c):
raise NotImp... | 1,585 | 23.4 | 106 | py |
dhypr | dhypr-main/code/baselines/manifolds/poincare.py | import torch
from manifolds.base import Manifold
from utils.math_utils import artanh, tanh
class PoincareBall(Manifold):
def __init__(self, ):
super(PoincareBall, self).__init__()
self.name = 'PoincareBall'
self.min_norm = 1e-15
self.eps = {torch.float32: 4e-3, torch.float64: 1e-5... | 5,027 | 34.659574 | 90 | py |
dhypr | dhypr-main/code/baselines/manifolds/hyperboloid.py | import torch
from manifolds.base import Manifold
from utils.math_utils import arcosh, cosh, sinh
import pdb
class Hyperboloid(Manifold):
def __init__(self):
super(Hyperboloid, self).__init__()
self.name = 'Hyperboloid'
self.eps = {torch.float32: 1e-7, torch.float64: 1e-15}
self.m... | 4,821 | 32.486111 | 88 | py |
dhypr | dhypr-main/code/D-HYPR/train.py | from __future__ import division
from __future__ import print_function
import datetime
import json
import logging
import os
import pickle
import time
import numpy as np
import optimizers
import torch
from config import parser
from models.base_models import NCModel, LPModel, SPModel
from utils.data_utils import load_da... | 8,558 | 39.563981 | 113 | py |
dhypr | dhypr-main/code/D-HYPR/models/decoders.py | import manifolds
import torch
import torch.nn as nn
import torch.nn.functional as F
from layers.layers import Linear
import pdb
class Decoder(nn.Module):
def __init__(self, c):
super(Decoder, self).__init__()
self.c = c
def decode(self, x, adj):
if self.decode_adj:
input ... | 2,079 | 28.714286 | 96 | py |
dhypr | dhypr-main/code/D-HYPR/models/base_models.py | import numpy as np
from sklearn.metrics import roc_auc_score, average_precision_score
import torch
import torch.nn as nn
import torch.nn.functional as F
from layers.layers import FermiDiracDecoder
from layers.layers import GravityDecoder
import manifolds
import layers.hyp_layers as hyp_layers
import models.encoders as... | 13,935 | 34.103275 | 112 | py |
dhypr | dhypr-main/code/D-HYPR/models/encoders.py | import numpy as np
import scipy.sparse as sp
import torch
import torch.nn as nn
import torch.nn.functional as F
import manifolds
import layers.hyp_layers as hyp_layers
from layers.layers import Linear
import utils.math_utils as pmath
import pdb
from utils.data_utils import sparse_mx_to_torch_sparse_tensor, normalize
... | 15,555 | 49.836601 | 121 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.