repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
nussl | nussl-master/tests/ml/test_gaussian_mixture.py | from nussl.ml.unfold import GaussianMixtureTorch
import torch
import numpy as np
from torch import nn
from sklearn.metrics import adjusted_mutual_info_score
from sklearn import mixture, cluster
def test_ml_gaussian_mixture():
loc = torch.randn(1, 1, 3, 2)
cov = torch.eye(2).view(1, 1, 1, 2, 2)
cov = cov.r... | 3,347 | 37.045455 | 83 | py |
nussl | nussl-master/tests/ml/test_trainer.py | from nussl import ml, datasets
import tempfile
from torch import optim
import numpy as np
import logging
import os
import torch
# uncomment if you want to see the trainer/engine logs
logging.basicConfig(
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:... | 9,232 | 37.152893 | 89 | py |
nussl | nussl-master/tests/ml/test_separation_model.py | import nussl
import torch
from torch import nn
from nussl.ml.networks import SeparationModel, modules, builders
from nussl import datasets
import pytest
import json
import tempfile
import copy
n_features = 257
mi_config = builders.build_recurrent_mask_inference(
n_features, 50, 2, True, 0.3, 2, 'softmax',
)
dpc... | 14,816 | 29.054767 | 78 | py |
nussl | nussl-master/tests/ml/test_loss.py | import torch
import nussl
from nussl import ml
from torch import nn
import numpy as np
from itertools import permutations
import random
import copy
def test_register_loss():
class ExampleLoss(nn.Module):
DEFAULT_KEYS = {'key1': 'arg1', 'key2': 'arg2'}
def forward(self, arg1, arg2):
ret... | 7,004 | 31.133028 | 83 | py |
nussl | nussl-master/tests/ml/test_modules.py | import torch
import nussl
from nussl.datasets import transforms
from nussl import ml
import pytest
import numpy as np
import librosa
import itertools
def test_register_module():
class ExampleModule(torch.nn.Module):
def forward(self, data):
data = data * 2
return data
assert E... | 12,748 | 29.573141 | 87 | py |
nussl | nussl-master/tests/ml/test_filterbank.py | from nussl import ml, datasets
from nussl.core.constants import ALL_WINDOWS
import nussl
import pytest
import torch
import itertools
from scipy.signal import check_COLA
import numpy as np
def test_filter_bank(one_item, monkeypatch):
pytest.raises(
NotImplementedError, ml.networks.modules.FilterBank, 2048)
... | 4,363 | 29.305556 | 92 | py |
nussl | nussl-master/tests/ml/test_confidence.py | from nussl import ml
import nussl
import torch
import numpy as np
from sklearn import datasets
import pytest
import copy
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
@pytest.fixture(scope="module")
def simple_sine_data():
nussl.utils.seed(0)
folder = 'ignored'
stft_params = nussl.STFTParams(w... | 9,796 | 31.440397 | 101 | py |
nussl | nussl-master/tests/ml/test_overfit.py | from nussl import ml, datasets, evaluation
import tempfile
from torch import optim
import numpy as np
import logging
import os
import torch
from matplotlib import pyplot as plt
logging.basicConfig(
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S'... | 3,197 | 31.969072 | 89 | py |
nussl | nussl-master/tests/ml/test_clustering.py | """
This file is a palceholder for if new clustering algorithms come into
nussl at some point and need to be tested.
"""
from sklearn import datasets
from sklearn.metrics import adjusted_mutual_info_score
from sklearn.preprocessing import StandardScaler
import sklearn
import numpy as np
import pytest
from nussl.ml im... | 2,411 | 36.107692 | 92 | py |
nussl | nussl-master/tests/ml/test_closures.py | from nussl import datasets, ml
from torch import optim, nn
import torch
import numpy as np
from nussl.ml.train.closures import ClosureException
import pytest
import nussl
def test_base_closure():
n_batch = 40
n_time = 400
n_freq = 129
n_sources = 4
n_embedding = 20
embedding = torch.rand(n_ba... | 8,352 | 27.030201 | 88 | py |
nussl | nussl-master/tests/ml/test_gradients.py | from nussl import ml, datasets, utils
import numpy as np
import torch
import matplotlib.pyplot as plt
import os
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
def test_gradients(mix_source_folder):
os.makedirs('tests/local/', exist_ok=True)
utils.seed(0)
tfms = datasets.transforms.Compose([
... | 7,122 | 35.906736 | 89 | py |
nussl | nussl-master/docs/stage_docs.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import argparse
import subprocess
def run(cmd):
print(cmd)
subprocess.run([cmd], shell=True)
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('docs_repo_path', type=str)
args_ = parser.parse_args()
return a... | 1,059 | 26.179487 | 78 | py |
nussl | nussl-master/docs/create_and_execute_notebook.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import glob
import argparse
def convert_execute_and_sync_script(script_path):
def run(cmd):
subprocess.run([cmd], shell=True)
notebook_path = script_path.replace('py', 'ipynb')
run(f"jupytext --update --to notebook {script_path}")
... | 1,337 | 29.409091 | 73 | py |
nussl | nussl-master/docs/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,957 | 27.718447 | 79 | py |
nussl | nussl-master/docs/tutorials/effects.py | # ---
# jupyter:
# jupytext:
# formats: py,ipynb
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.0
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Data augmentation
# =========... | 11,484 | 32.879056 | 423 | py |
nussl | nussl-master/docs/tutorials/training.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Training deep models in *nuss... | 38,430 | 32.476481 | 304 | py |
nussl | nussl-master/docs/tutorials/audio_signal_basics.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 4,887 | 33.181818 | 244 | py |
nussl | nussl-master/docs/tutorials/masking_audio_signals.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Separation via Time-Fre... | 5,798 | 28.586735 | 89 | py |
nussl | nussl-master/docs/tutorials/datasets.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Handling data in *nussl... | 17,169 | 30.275046 | 100 | py |
nussl | nussl-master/docs/tutorials/repet.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Running REPET
# =======... | 4,427 | 29.122449 | 165 | py |
nussl | nussl-master/docs/tutorials/evaluation.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# Evaluating separation p... | 9,410 | 31.564014 | 92 | py |
nussl | nussl-master/docs/tutorials/audio_signal_stft.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# + [markdown] raw_mimety... | 6,075 | 35.166667 | 210 | py |
nussl | nussl-master/docs/examples/composite/ensemble_clustering.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Ensemble Clustering
#... | 2,133 | 24.710843 | 73 | py |
nussl | nussl-master/docs/examples/spatial/duet.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # DUET
#
# Rickard, Sco... | 1,676 | 23.304348 | 64 | py |
nussl | nussl-master/docs/examples/spatial/spatial_clustering.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Spatial clustering
#
... | 5,301 | 30.939759 | 139 | py |
nussl | nussl-master/docs/examples/spatial/projet.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 3,113 | 25.389831 | 108 | py |
nussl | nussl-master/docs/examples/deep/deep_mask_estimation.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 3,415 | 31.846154 | 132 | py |
nussl | nussl-master/docs/examples/deep/deep_clustering.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Deep clustering
#
# H... | 2,594 | 29.174419 | 107 | py |
nussl | nussl-master/docs/examples/benchmark/high_pass_filter.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 1,432 | 20.073529 | 57 | py |
nussl | nussl-master/docs/examples/benchmark/ideal_ratio_mask.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 2,086 | 23.267442 | 69 | py |
nussl | nussl-master/docs/examples/benchmark/mix_as_estimate.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 1,205 | 20.535714 | 54 | py |
nussl | nussl-master/docs/examples/benchmark/ideal_binary_mask.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 1,348 | 21.483333 | 55 | py |
nussl | nussl-master/docs/examples/benchmark/wiener_filter.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 4,554 | 31.769784 | 150 | py |
nussl | nussl-master/docs/examples/primitives/2dft.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # 2DFT
#
# Seetharaman,... | 2,159 | 27.421053 | 108 | py |
nussl | nussl-master/docs/examples/primitives/melodia.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 2,636 | 28.3 | 100 | py |
nussl | nussl-master/docs/examples/primitives/timbre.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Timbre clustering
#
#... | 1,772 | 25.863636 | 94 | py |
nussl | nussl-master/docs/examples/primitives/hpss.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 2,253 | 24.044444 | 80 | py |
nussl | nussl-master/docs/examples/primitives/repet_sim.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# REPETSIM
# ========
#
#... | 1,709 | 25.71875 | 98 | py |
nussl | nussl-master/docs/examples/primitives/repet.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # REPET
#
# Rafii, Zafa... | 1,778 | 26.369231 | 107 | py |
nussl | nussl-master/docs/examples/factorization/ica.py | # -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
#... | 2,316 | 22.642857 | 76 | py |
nussl | nussl-master/docs/examples/factorization/rpca.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.5.1
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Robust Principal Comp... | 1,985 | 26.583333 | 108 | py |
nussl | nussl-master/docs/recipes/wham/ideal_ratio_mask.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# notebook_metadata_filter: nbsphinx
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.4.1
# kernelspec:
# display_name: Python 3
# language: python
# name:... | 3,780 | 27.007407 | 80 | py |
nussl | nussl-master/docs/recipes/wham/ideal_binary_mask.py | # ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# notebook_metadata_filter: nbsphinx
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.4.1
# kernelspec:
# display_name: Python 3
# language: python
# name:... | 2,532 | 25.385417 | 76 | py |
RE-Net | RE-Net-master/pretrain.py | import argparse
import numpy as np
import time
import torch
import utils
import os
from global_model import RENet_global
from sklearn.utils import shuffle
import pickle
def train(args):
# load data
num_nodes, num_rels = utils.get_total_number('./data/' + args.dataset, 'stat.txt')
train_data, train_times_o... | 5,489 | 37.93617 | 115 | py |
RE-Net | RE-Net-master/test.py | import argparse
import numpy as np
import torch
import utils
import os
from model import RENet
from global_model import RENet_global
import pickle
def test(args):
# load data
num_nodes, num_rels = utils.get_total_number('./data/' + args.dataset, 'stat.txt')
if args.dataset == 'icews_know':
train_d... | 6,522 | 36.705202 | 119 | py |
RE-Net | RE-Net-master/RGCN.py | import torch
import torch.nn as nn
import dgl.function as fn
class RGCNLayer(nn.Module):
def __init__(self, in_feat, out_feat, bias=None, activation=None,
self_loop=False, dropout=0.0):
super(RGCNLayer, self).__init__()
self.bias = bias
self.activation = activation
... | 3,494 | 35.789474 | 102 | py |
RE-Net | RE-Net-master/utils.py | import numpy as np
import os
import dgl
import torch
from collections import defaultdict
def get_total_number(inPath, fileName):
with open(os.path.join(inPath, fileName), 'r') as fr:
for line in fr:
line_split = line.split()
return int(line_split[0]), int(line_split[1])
def load_... | 11,375 | 34.003077 | 185 | py |
RE-Net | RE-Net-master/model.py | import torch.nn as nn
import numpy as np
import torch
import torch.nn.functional as F
from Aggregator import MeanAggregator, AttnAggregator, RGCNAggregator
from utils import *
import time
class RENet(nn.Module):
def __init__(self, in_dim, h_dim, num_rels, dropout=0, model=0, seq_len=10, num_k=10):
super(R... | 19,170 | 41.792411 | 175 | py |
RE-Net | RE-Net-master/Aggregator.py | import torch.nn as nn
import numpy as np
import torch
import torch.nn.functional as F
from utils import *
from RGCN import RGCNBlockLayer as RGCNLayer
class RGCNAggregator_global(nn.Module):
def __init__(self, h_dim, dropout, num_nodes, num_rels, num_bases, model, seq_len=10, maxpool=1):
super(RGCNAggrega... | 15,591 | 41.835165 | 157 | py |
RE-Net | RE-Net-master/global_model.py | import torch.nn as nn
import numpy as np
import torch
import torch.nn.functional as F
from Aggregator import RGCNAggregator_global
from utils import *
import time
class RENet_global(nn.Module):
def __init__(self, in_dim, h_dim, num_rels, dropout=0, model=0, seq_len=10, num_k=10, maxpool=1):
super(RENet_gl... | 3,002 | 29.333333 | 111 | py |
RE-Net | RE-Net-master/train.py | import argparse
import numpy as np
import time
import torch
import utils
import os
from model import RENet
from global_model import RENet_global
from sklearn.utils import shuffle
import pickle
def train(args):
# load data
num_nodes, num_rels = utils.get_total_number('./data/' + args.dataset, 'stat.txt')
i... | 10,762 | 43.292181 | 152 | py |
RE-Net | RE-Net-master/baselines/TATransE.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-24 01:45:03
# @Author : jimmy (jimmywangheng@qq.com)
# @Link : http://sdcs.sysu.edu.cn
# @Version : $Id$
import os
import torch
torch.multiprocessing.set_start_method("spawn")
import torch.autograd as autograd
import torch.nn as nn
import torch.nn... | 16,007 | 43.715084 | 200 | py |
RE-Net | RE-Net-master/baselines/evaluation_TTransE.py | import torch
import torch.autograd as autograd
from sklearn.metrics.pairwise import pairwise_distances, cosine_similarity
from data import *
from eval_lib import *
USE_CUDA = torch.cuda.is_available()
if USE_CUDA:
longTensor = torch.cuda.LongTensor
floatTensor = torch.cuda.FloatTensor
else:
longTensor ... | 6,469 | 36.836257 | 193 | py |
RE-Net | RE-Net-master/baselines/TADistmult.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-24 01:45:03
# @Author : jimmy (jimmywangheng@qq.com)
# @Link : http://sdcs.sysu.edu.cn
# @Version : $Id$
import os
import torch
torch.multiprocessing.set_start_method("spawn")
import torch.autograd as autograd
import torch.nn as nn
import torch.nn... | 18,104 | 44.835443 | 200 | py |
RE-Net | RE-Net-master/baselines/loss.py | import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
USE_CUDA = torch.cuda.is_available()
if USE_CUDA:
longTensor = torch.cuda.LongTensor
floatTensor = torch.cuda.FloatTensor
else:
longTensor = torch.LongTensor
floatTensor = torch.FloatTe... | 1,481 | 30.531915 | 142 | py |
RE-Net | RE-Net-master/baselines/utils.py | import os
import numpy as np
class Triple(object):
def __init__(self, head, tail, relation):
self.s = head
self.o = tail
self.r = relation
# self.t = tim
class Quadruple(object):
def __init__(self, head, tail, relation, tim):
self.s = head
self.o = tail
... | 4,738 | 32.609929 | 129 | py |
RE-Net | RE-Net-master/baselines/model.py | import os
import math
import pickle
import numpy as np
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from LSTMLinear import LSTMModel
USE_CUDA = torch.cuda.is_available()
if USE_CUDA:
longTensor = torch.cuda.LongTensor
floatTensor = ... | 8,996 | 36.962025 | 87 | py |
RE-Net | RE-Net-master/baselines/eval_lib.py | import torch
import torch.autograd as autograd
USE_CUDA = torch.cuda.is_available()
if USE_CUDA:
longTensor = torch.cuda.LongTensor
floatTensor = torch.cuda.FloatTensor
else:
longTensor = torch.LongTensor
floatTensor = torch.FloatTensor
def isHit10(triple, tree, cal_embedding, tripleDict, isTail):
... | 1,836 | 28.15873 | 71 | py |
RE-Net | RE-Net-master/baselines/data.py | import os
import random
from copy import deepcopy
import numpy as np
import operator
from utils import Triple
# Change the head of a triple randomly,
# without checking whether it is a false negative sample.
def corrupt_head_raw(quadruple, entityTotal):
newQuadruple = deepcopy(quadruple)
oldHead = quadruple.s... | 6,703 | 42.816993 | 116 | py |
RE-Net | RE-Net-master/baselines/evaluation_TADistMult.py | import os
import numpy as np
import time
import datetime
import random
import multiprocessing
import math
import torch
import torch.autograd as autograd
from sklearn.metrics.pairwise import pairwise_distances, cosine_similarity, linear_kernel
from data import *
from eval_lib import *
USE_CUDA = torch.cuda.is_availab... | 6,125 | 34.005714 | 161 | py |
RE-Net | RE-Net-master/baselines/evaluation_TATransE.py | import numpy as np
import torch
import torch.autograd as autograd
from sklearn.metrics.pairwise import pairwise_distances, cosine_similarity
from data import *
from eval_lib import *
USE_CUDA = torch.cuda.is_available()
if USE_CUDA:
longTensor = torch.cuda.LongTensor
floatTensor = torch.cuda.FloatTensor
el... | 6,301 | 35.218391 | 161 | py |
RE-Net | RE-Net-master/baselines/TTransE.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2017-12-24 01:45:03
# @Author : jimmy (jimmywangheng@qq.com)
# @Link : http://sdcs.sysu.edu.cn
# @Version : $Id$
import os
import torch
torch.multiprocessing.set_start_method("spawn")
import torch.autograd as autograd
import torch.nn as nn
import torch.nn... | 15,907 | 44.451429 | 235 | py |
RE-Net | RE-Net-master/baselines/LSTMLinear.py | import math
import torch as th
import torch
from torch import nn
import numpy as np
class LSTMModel(nn.Module):
def __init__(self, in_dim, n_layer):
super(LSTMModel, self).__init__()
self.n_layer = n_layer
self.hidden_dim = in_dim
# self.lstm = nn.LSTM(in_dim, self.hidden_dim, n_l... | 2,897 | 28.571429 | 81 | py |
RE-Net | RE-Net-master/baselines/data/preprocess_TTransE.py | # make timestamps to time index
import numpy as np
import sys
import os
time_dict = {}
dataset = sys.argv[1]
path = '../data/' + dataset
os.makedirs(dataset + '_TTransE', exist_ok=True)
newpath = 'data/' + dataset + '_TTransE/'
fr_stat = open(path + "stat.txt", "r")
fw_stat = open(newpath + "stat.txt", "w")
count =... | 1,227 | 24.061224 | 99 | py |
RE-Net | RE-Net-master/baselines/data/preprocess_TA_step2.py | import numpy as np
import sys
import os
# tem_dict
tem_dict = {
'0y': 0, '1y': 1, '2y': 2, '3y': 3, '4y': 4, '5y': 5, '6y': 6, '7y': 7, '8y': 8, '9y': 9,
'01m': 10, '02m': 11, '03m': 12, '04m': 13, '05m': 14, '06m': 15, '07m': 16, '08m': 17, '09m': 18, '10m': 19, '11m': 20, '12m': 21,
'0d': 22, '1d': 23, '... | 1,467 | 27.784314 | 135 | py |
RE-Net | RE-Net-master/baselines/data/preprocess_TA_step1.py | # make timestamps to datetime format
import datetime
import os
import sys
dataset = sys.argv[1]
path = '../data/' + dataset
os.makedirs(dataset + '_TA', exist_ok=True)
newpath = 'data/' + dataset + '_TA/'
filelist = os.listdir(path)
for filename in filelist:
if filename.startswith("stat"):
continue
fp... | 878 | 24.852941 | 101 | py |
RE-Net | RE-Net-master/data/YAGO/get_history_graph.py | import numpy as np
import os
from collections import defaultdict
import pickle
import dgl
import torch
def load_quadruples(inPath, fileName, fileName2=None):
with open(os.path.join(inPath, fileName), 'r') as fr:
quadrupleList = []
times = set()
for line in fr:
line_split = line... | 10,633 | 32.23125 | 97 | py |
RE-Net | RE-Net-master/data/ICEWS14/get_history_graph.py | import numpy as np
import os
from collections import defaultdict
import pickle
import dgl
import torch
def load_quadruples(inPath, fileName, fileName2=None):
with open(os.path.join(inPath, fileName), 'r') as fr:
quadrupleList = []
times = set()
for line in fr:
line_split = line... | 10,737 | 32.661442 | 97 | py |
RE-Net | RE-Net-master/data/ICEWS18/get_history_graph.py | import numpy as np
import os
from collections import defaultdict
import pickle
import dgl
import torch
def load_quadruples(inPath, fileName, fileName2=None):
with open(os.path.join(inPath, fileName), 'r') as fr:
quadrupleList = []
times = set()
for line in fr:
line_split = line... | 10,633 | 32.23125 | 97 | py |
RE-Net | RE-Net-master/data/WIKI/get_history_graph.py | import numpy as np
import os
from collections import defaultdict
import pickle
import dgl
import torch
def load_quadruples(inPath, fileName, fileName2=None):
with open(os.path.join(inPath, fileName), 'r') as fr:
quadrupleList = []
times = set()
for line in fr:
line_split = line... | 10,633 | 32.23125 | 97 | py |
RE-Net | RE-Net-master/data/GDELT/get_history_graph.py | import numpy as np
import os
from collections import defaultdict
import pickle
import dgl
import torch
def load_quadruples(inPath, fileName, fileName2=None):
with open(os.path.join(inPath, fileName), 'r') as fr:
quadrupleList = []
times = set()
for line in fr:
line_split = line... | 10,633 | 32.23125 | 97 | py |
TABGP | TABGP-main/tbgp/configs/config.gen.py | import sys, getopt
#epl.ta0-4.path4.toml epl.ta0-4.rectangle.toml eu-email.ta0-4.path4 eu-email.ta0-4.rectange.toml
def main(argv):
inputfile = ''
nfafile = ''
debugconfig = '1'
pattern_type = ''
pattern_size = ''
try:
opts, args = getopt.getopt(argv,"hi:t:d:p:s:")
except getopt... | 1,282 | 28.837209 | 106 | py |
asplos22-ae | asplos22-ae-main/experiments/fig-06_nginx-redis-perm/apps/nginx/plot.py | #!/usr/bin/python3
import os
import sys
import csv
import pprint
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from collections import OrderedDict
from matplotlib.colors import LogNorm
# mpl.use('TkAgg')
pp = pprint.PrettyPrinter(indent=4)
THROUGHPUT = 'throughput'
MEAN_KEY = 'mean'
MED... | 10,792 | 25.915212 | 95 | py |
asplos22-ae | asplos22-ae-main/experiments/fig-06_nginx-redis-perm/apps/redis/plot.py | #!/usr/bin/python3
import os
import sys
import csv
import pprint
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from collections import OrderedDict
from matplotlib.colors import LogNorm
# mpl.use('TkAgg')
pp = pprint.PrettyPrinter(indent=4)
THROUGHPUT = 'throughput'
MEAN_KEY = 'mean'
MED... | 11,292 | 26.212048 | 95 | py |
asplos22-ae | asplos22-ae-main/experiments/fig-07_nginx-redis-normalized/plot_scatter.py | import sys
import os
import csv
import matplotlib.pyplot as plt
def check_equal_permutations(perm1, perm2):
res1 = ""
for i in perm1.keys():
res1 += perm1[i]
res2 = ""
for j in perm2.keys():
res2 += perm2[j]
return res1 == res2
def collate(permutations_file_redis=None, perm... | 6,004 | 35.840491 | 129 | py |
esp-idf | esp-idf-master/conftest.py | # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
# pylint: disable=W0621 # redefined-outer-name
# This file is a pytest root configuration file and provide the following functionalities:
# 1. Defines a few fixtures that could be used under the whole projec... | 28,452 | 38.137552 | 143 | py |
esp-idf | esp-idf-master/tools/idf_monitor.py | #
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
import subprocess
import sys
if __name__ == '__main__':
sys.exit(subprocess.run([sys.executable, '-m', 'esp_idf_monitor'] + sys.argv[1:]).returncode)
| 267 | 21.333333 | 97 | py |
esp-idf | esp-idf-master/tools/idf.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
# 'idf.py' is a top-level config/build command line tool for ESP-IDF
#
# You don't have to use idf.py, you can use cmake directly
# (or use cmake in an IDE)
# WARNING: we don't chec... | 33,786 | 41.986005 | 147 | py |
esp-idf | esp-idf-master/tools/check_term.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import print_function
import os
import sys
if __name__ == '__main__':
# Checks for the content of environment variable TERM to use with the Python- and curses-base... | 1,481 | 45.3125 | 116 | py |
esp-idf | esp-idf-master/tools/mkdfu.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# This program creates archives compatible with ESP32-S* ROM DFU implementation.
#
# The archives are in CPIO format. Each file which needs to be flashed is added to the archive
# as a... | 11,526 | 33.824773 | 116 | py |
esp-idf | esp-idf-master/tools/gdb_panic_server.py | #!/usr/bin/env python
# coding=utf-8
#
# A script which parses ESP-IDF panic handler output (registers & stack dump),
# and then acts as a GDB server over stdin/stdout, presenting the information
# from the panic handler to GDB.
# This allows for generating backtraces out of raw stack dumps on architectures
# where bac... | 11,267 | 37.989619 | 119 | py |
esp-idf | esp-idf-master/tools/check_python_dependencies.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import os
import re
import sys
try:
from packaging.requirements import Requirement
from packaging.version import Version
except ImportError:
print('packagin... | 7,131 | 48.874126 | 124 | py |
esp-idf | esp-idf-master/tools/idf_size.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
import subprocess
import sys
if __name__ == '__main__':
sys.exit(subprocess.run([sys.executable, '-m', 'esp_idf_size'] + sys.argv[1:]).returncode)
| 291 | 21.461538 | 94 | py |
esp-idf | esp-idf-master/tools/generate_debug_prefix_map.py | # SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
# General Workflow:
# 1. read all components dirs, a semicolon-separated string (cmake list)
# 2. map the component dir with a unique prefix /COMPONENT_<NAME>_DIR
# 2. write the prefix mapping file to $BUILD_DIR/pr... | 1,646 | 34.804348 | 116 | py |
esp-idf | esp-idf-master/tools/install_util.py | #!/usr/bin/env python
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
# This script is used from the $IDF_PATH/install.* scripts. This way the argument parsing can be done at one place and
# doesn't have to be implemented for all shells.
import argparse... | 4,100 | 35.945946 | 153 | py |
esp-idf | esp-idf-master/tools/python_version_checker.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
# Script for checking the compatibility of the Python interpreter with ESP-IDF.
#
# There are related tools/detect_python.{sh,fish} scripts which are called earlier when the paths ar... | 1,574 | 33.23913 | 115 | py |
esp-idf | esp-idf-master/tools/split_paths_by_spaces.py | #!/usr/bin/env python
# coding=utf-8
#
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
# This script converts space-separated EXTRA_COMPONENT_DIRS and COMPONENT_DIRS
# CMake variables into semicolon-separated lists.
#
# IDF versions <=v4.4 didn't support... | 14,575 | 42.640719 | 119 | py |
esp-idf | esp-idf-master/tools/gen_esp_err_to_name.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import collections
import fnmatch
import functools
import os
import re
import textwrap
from io import open
from typing import Any, List, Optional, TextIO
# list files h... | 14,241 | 39.345609 | 150 | py |
esp-idf | esp-idf-master/tools/idf_tools.py | #!/usr/bin/env python
# coding=utf-8
#
# SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
# This script helps installing tools required to use the ESP-IDF, and updating PATH
# to use the installed tools. It can also create a Python virtual environment,
# an... | 121,873 | 44.222263 | 160 | py |
esp-idf | esp-idf-master/tools/mkuf2.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import division
import argparse
import hashlib
import json
import os
import struct
from functools import partial
from typing import Dict, List
def round_up_int_div(n:... | 7,488 | 37.209184 | 117 | py |
esp-idf | esp-idf-master/tools/esp_prov/esp_prov.py | #!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import argparse
import asyncio
import json
import os
import sys
import textwrap
import time
from getpass import getpass
try:
import prov
import security
import transport
... | 21,261 | 38.742056 | 128 | py |
esp-idf | esp-idf-master/tools/esp_prov/__init__.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
from .esp_prov import * # noqa: export esp_prov module to users
| 178 | 28.833333 | 71 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/security1.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# APIs for interpreting and creating protobuf packets for
# protocomm endpoint with security type protocomm_security1
import proto
from cryptography.hazmat.backends import default_backend
from cryptography.... | 6,322 | 43.843972 | 109 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/security.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# Base class for protocomm security
class Security:
def __init__(self, security_session):
self.security_session = security_session
| 258 | 22.545455 | 71 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/srp6a.py | # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# N A large safe prime (N = 2q+1, where q is prime) [All arithmetic is done modulo N]
# g A generator modulo N
# k Multiplier parameter (k = H(N, g) in SRP-6a, k = 3 for legacy SRP-6)
# s User's s... | 10,228 | 32.870861 | 131 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/security2.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
# APIs for interpreting and creating protobuf packets for
# protocomm endpoint with security type protocomm_security2
from typing import Any, Type
import proto
from cryptography.hazmat.primitives.ciphers.ae... | 6,752 | 39.680723 | 100 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/__init__.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
from .security0 import * # noqa: F403, F401
from .security1 import * # noqa: F403, F401
from .security2 import * # noqa: F403, F401
| 248 | 30.125 | 71 | py |
esp-idf | esp-idf-master/tools/esp_prov/security/security0.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
# APIs for interpreting and creating protobuf packets for
# protocomm endpoint with security type protocomm_security0
import proto
from utils import str_to_bytes
from .security import Security
class Secu... | 1,860 | 33.462963 | 71 | py |
esp-idf | esp-idf-master/tools/esp_prov/proto/__init__.py | # SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import importlib.util
import os
import sys
from importlib.abc import Loader
from typing import Any
def _load_source(name: str, path: str) -> Any:
spec = importlib.util.spec_from_file_location(name, pat... | 1,745 | 44.947368 | 128 | py |
esp-idf | esp-idf-master/tools/esp_prov/utils/__init__.py | # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
from .convenience import * # noqa: F403, F401
| 155 | 25 | 66 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.