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 |
|---|---|---|---|---|---|---|
ReBATE | ReBATE-master/rebate/setup_multisurf.py | """
Copyright (c) 2016 Peter R. Schmitt and Ryan J. Urbanowicz
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, me... | 1,332 | 42 | 74 | py |
ReBATE | ReBATE-master/tests/tests_continuous_endpoint.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 9,736 | 41.334783 | 141 | py |
ReBATE | ReBATE-master/tests/tests_missing_data.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 9,708 | 41.213043 | 141 | py |
ReBATE | ReBATE-master/tests/tests_mixed_features.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 9,829 | 41.73913 | 141 | py |
ReBATE | ReBATE-master/tests/tests_gwas_sim.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 10,841 | 40.224335 | 141 | py |
ReBATE | ReBATE-master/tests/tests_6_bit_multiplexer.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 9,930 | 40.902954 | 147 | py |
ReBATE | ReBATE-master/tests/tests_multiclass.py |
"""
ReBATE was primarily developed at the University of Pennsylvania by:
- Pete Schmitt ([email protected])
- Ryan J. Urbanowicz ([email protected])
- Weixuan Fu ([email protected])
- and many more generous open source contributors
Permission is hereby granted, free of charge, to any person obtainin... | 9,570 | 40.79476 | 141 | py |
iterative_cleaner | iterative_cleaner-master/iterative_cleaner.py | #!/usr/bin/env python
# Tool to remove RFI from pulsar archives.
# Originally written by Patrick Lazarus. Modified by Lars Kuenkel.
from __future__ import print_function
import numpy as np
import datetime
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import scipy.optimize
import argparse
import psrchive
... | 13,854 | 39.630499 | 153 | py |
URLNet | URLNet-master/test.py | from utils import *
import pickle
import time
from tqdm import tqdm
import argparse
import numpy as np
import pickle
import tensorflow as tf
from tensorflow.contrib import learn
from tflearn.data_utils import to_categorical, pad_sequences
parser = argparse.ArgumentParser(description="Test URLNet model")
# data... | 8,848 | 47.092391 | 167 | py |
URLNet | URLNet-master/auc.py | import numpy as np
import argparse
import pdb
parser = argparse.ArgumentParser(description='Nill')
parser.add_argument('--input_path', default="results/svm_bow_lexical/baseline1/", type=str)
parser.add_argument('--input_file', type=str)
parser.add_argument('--threshold', default=0, type=float)
args = parser.parse_args... | 2,436 | 26.382022 | 91 | py |
URLNet | URLNet-master/utils.py | import time
import os
import numpy as np
from collections import defaultdict
from bisect import bisect_left
import tensorflow as tf
from tflearn.data_utils import to_categorical
from tensorflow.contrib import learn
def read_data(file_dir):
with open(file_dir) as file:
urls = []
labels = []
... | 14,170 | 34.605528 | 125 | py |
URLNet | URLNet-master/TextCNN.py | import tensorflow as tf
class TextCNN(object):
def __init__(self, char_ngram_vocab_size, word_ngram_vocab_size, char_vocab_size, \
word_seq_len, char_seq_len, embedding_size, l2_reg_lambda=0, \
filter_sizes=[3,4,5,6], mode=0):
if mode == 4 or mode == 5:
self.input_x_char = t... | 8,998 | 55.955696 | 141 | py |
URLNet | URLNet-master/train.py | import re
import time
import datetime
import os
import pdb
import pickle
import argparse
import numpy as np
from tqdm import tqdm
from bisect import bisect_left
import tensorflow as tf
from tensorflow.contrib import learn
from tflearn.data_utils import to_categorical, pad_sequences
from TextCNN import *
from... | 14,237 | 46.145695 | 184 | py |
NeuralKG | NeuralKG-main/main.py | # -*- coding: utf-8 -*-
# from torch._C import T
# from train import Trainer
import pytorch_lightning as pl
from pytorch_lightning import seed_everything
from IPython import embed
import wandb
from neuralkg.utils import setup_parser
from neuralkg.utils.tools import *
from neuralkg.data.Sampler import *
from neuralkg.da... | 4,261 | 33.934426 | 86 | py |
NeuralKG | NeuralKG-main/setup.py | #!/usr/bin/env python
# coding: utf-8
import setuptools
import os
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name='neuralkg',
version='1.0.21',
author='ZJUKG',
author_email='[email protected]',
url='https://github.com/zjukg/NeuralKG',
descriptio... | 907 | 24.942857 | 97 | py |
NeuralKG | NeuralKG-main/demo.py | # -*- coding: utf-8 -*-
# from torch._C import T
# from train import Trainer
import pytorch_lightning as pl
from pytorch_lightning import seed_everything
from IPython import embed
import wandb
from neuralkg.utils import setup_parser
from neuralkg.utils.tools import *
from neuralkg.data.Sampler import *
from neuralkg.da... | 4,592 | 36.647541 | 88 | py |
NeuralKG | NeuralKG-main/dataset/demo_kg/data-preprocess.py | train = './train.txt'
entity2id = './entity2id.txt'
relation2id = './relation2id.txt'
entity = set()
relation = set()
def write_dict(name):
if name == "entity":
read_path = entity2id
write_path = "./entities.dict"
else:
read_path = relation2id
write_path = "./relations.dict"
kk = open(write_path, "w")
with... | 499 | 17.518519 | 39 | py |
NeuralKG | NeuralKG-main/src/neuralkg/__init__.py | from .data import *
from .eval_task import *
from .lit_model import *
from .loss import *
from .model import *
from .utils import * | 131 | 21 | 24 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/RugELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from neuralkg import loss
from .BaseLitModel import BaseLitModel
from neuralkg.eval_... | 3,391 | 35.869565 | 103 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/XTransELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 2,658 | 35.930556 | 100 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/SEGNNLitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
import dgl
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
... | 4,053 | 34.876106 | 115 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/RGCNLitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 2,602 | 36.185714 | 100 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/KGELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from .BaseLitModel import BaseLitModel
from IPython import embed
from neuralkg.eval_task import *
from IPython... | 3,834 | 32.938053 | 100 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/CrossELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 2,908 | 37.276316 | 123 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/BaseLitModel.py | import argparse
import pytorch_lightning as pl
import torch
from collections import defaultdict as ddict
from neuralkg import loss
import numpy as np
class Config(dict):
def __getattr__(self, name):
return self.get(name)
def __setattr__(self, name, val):
self[name] = val
class BaseLitMode... | 2,337 | 31.472222 | 118 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/__init__.py | from .BaseLitModel import BaseLitModel
from .KGELitModel import KGELitModel
from .ConvELitModel import ConvELitModel
from .RGCNLitModel import RGCNLitModel
from .KBATLitModel import KBATLitModel
from .CompGCNLitModel import CompGCNLitModel
from .CrossELitModel import CrossELitModel
from .XTransELitModel import XTransEL... | 448 | 39.818182 | 44 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/CompGCNLitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 2,737 | 36.506849 | 103 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/ConvELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 2,572 | 34.246575 | 100 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/IterELitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 4,230 | 40.07767 | 139 | py |
NeuralKG | NeuralKG-main/src/neuralkg/lit_model/KBATLitModel.py | from logging import debug
import pytorch_lightning as pl
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import os
import json
from collections import defaultdict as ddict
from IPython import embed
from .BaseLitModel import BaseLitModel
from neuralkg.eval_task import *
from IPython... | 3,269 | 37.928571 | 105 | py |
NeuralKG | NeuralKG-main/src/neuralkg/eval_task/link_prediction_SEGNN.py | import torch
import os
from IPython import embed
#TODO: SEGNN
def link_predict_SEGNN(batch, kg, model, prediction="all"):
"""The evaluate task is predicting the head entity or tail entity in incomplete triples.
Args:
batch: The batch of the triples for validation or test.
model: The KG... | 3,206 | 35.443182 | 107 | py |
NeuralKG | NeuralKG-main/src/neuralkg/eval_task/link_prediction.py | import torch
import os
from IPython import embed
def link_predict(batch, model, prediction="all"):
"""The evaluate task is predicting the head entity or tail entity in incomplete triples.
Args:
batch: The batch of the triples for validation or test.
model: The KG model for training.
... | 2,582 | 29.034884 | 95 | py |
NeuralKG | NeuralKG-main/src/neuralkg/eval_task/__init__.py | from .link_prediction import *
from .link_prediction_SEGNN import * | 67 | 33 | 36 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/KBAT_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
class KBAT_Loss(nn.Module):
def __init__(self, args, model):
super(KBAT_Loss, self).__init__()
self.args = args
self.model = model
self.GAT_loss = nn.MarginRankingLoss(self.args.margin)
self.Con_loss = nn.So... | 774 | 34.227273 | 91 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/ComplEx_NNE_AER_Loss.py | import torch
import torch.nn as nn
from IPython import embed
from neuralkg.data import KGData
class ComplEx_NNE_AER_Loss(nn.Module):
def __init__(self, args, model):
super(ComplEx_NNE_AER_Loss, self).__init__()
self.args = args
self.model = model
self.rule_p, self.rule_q = model.ru... | 1,497 | 36.45 | 70 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/Cross_Entropy_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class Cross_Entropy_Loss(nn.Module):
"""Binary CrossEntropyLoss
Attributes:
args: Some pre-set parameters, etc
model: The KG model for training.
"""
def __init__(self, args, model):
s... | 1,003 | 30.375 | 92 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/SimplE_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class SimplE_Loss(nn.Module):
def __init__(self, args, model):
super(SimplE_Loss, self).__init__()
self.args = args
self.model = model
def forward(self, pos_score, neg_score):
pos_score ... | 542 | 26.15 | 93 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/RugE_Loss.py | import torch
import torch.nn as nn
import math
from torch.autograd import Variable
from IPython import embed
class RugE_Loss(nn.Module):
def __init__(self,args, model):
super(RugE_Loss, self).__init__()
self.args = args
self.model = model
def forward(self, pos_score, neg_score, rule, co... | 5,328 | 42.325203 | 137 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/CrossE_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class CrossE_Loss(nn.Module):
def __init__(self, args, model):
super(CrossE_Loss, self).__init__()
self.args = args
self.model = model
def forward(self, score, label):
pos = torch.log(... | 713 | 34.7 | 94 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/Margin_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class Margin_Loss(nn.Module):
"""Margin Ranking Loss
Attributes:
args: Some pre-set parameters, etc
model: The KG model for training.
"""
def __init__(self, args, model):
super(Margin_... | 1,040 | 30.545455 | 100 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/RGCN_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
class RGCN_Loss(nn.Module):
def __init__(self, args, model):
super(RGCN_Loss, self).__init__()
self.args = args
self.model = model
def reg_loss(self):
return torch.mean(self.model.Loss_emb.pow(2)) + torch.... | 558 | 28.421053 | 93 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/Adv_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class Adv_Loss(nn.Module):
"""Negative sampling loss with self-adversarial training.
Attributes:
args: Some pre-set parameters, such as self-adversarial temperature, etc.
model: The KG model for trai... | 2,791 | 41.30303 | 232 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/Softplus_Loss.py | import torch
import torch.nn.functional as F
import torch.nn as nn
from IPython import embed
class Softplus_Loss(nn.Module):
"""softplus loss.
Attributes:
args: Some pre-set parameters, etc.
model: The KG model for training.
"""
def __init__(self, args, model):
super(Softplus_... | 1,754 | 39.813953 | 155 | py |
NeuralKG | NeuralKG-main/src/neuralkg/loss/__init__.py | from .Adv_Loss import Adv_Loss
from .ComplEx_NNE_AER_Loss import ComplEx_NNE_AER_Loss
from .SimplE_Loss import SimplE_Loss
from .Cross_Entropy_Loss import Cross_Entropy_Loss
from .RGCN_Loss import RGCN_Loss
from .KBAT_Loss import KBAT_Loss
from .CrossE_Loss import CrossE_Loss
from .Margin_Loss import Margin_Loss
from .... | 387 | 37.8 | 54 | py |
NeuralKG | NeuralKG-main/src/neuralkg/utils/setup_parser.py | # -*- coding: utf-8 -*-
import argparse
import os
import yaml
import pytorch_lightning as pl
from neuralkg import lit_model
from neuralkg import data
def setup_parser():
"""Set up Python's ArgumentParser with data, model, trainer, and other arguments."""
parser = argparse.ArgumentParser(add_help=False)
# A... | 9,625 | 69.262774 | 182 | py |
NeuralKG | NeuralKG-main/src/neuralkg/utils/tools.py | import importlib
from IPython import embed
import os
import time
import yaml
import torch
from torch.nn import Parameter
from torch.nn.init import xavier_normal_
def import_class(module_and_class_name: str) -> type:
"""Import class from a module, e.g. 'model.TransE'"""
module_name, class_name = module_and_clas... | 1,287 | 32.025641 | 95 | py |
NeuralKG | NeuralKG-main/src/neuralkg/utils/__init__.py | from .setup_parser import setup_parser
from .tools import * | 59 | 29 | 38 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/KGDataModule.py | """Base DataModule class."""
from pathlib import Path
from typing import Dict
import argparse
import os
from torch.utils.data import DataLoader
from .base_data_module import *
import pytorch_lightning as pl
class KGDataModule(BaseDataModule):
"""
Base DataModule.
Learn more at https://pytorch-lightning.re... | 3,501 | 33.333333 | 167 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/Grounding.py | from .DataPreprocess import KGData
import pdb
class GroundAllRules:
def __init__(self, args):
self.MapRelation2ID = {}
self.MapEntity2ID = {}
self.Relation2Tuple = {}
self.MapID2Entity = {}
self.MapID2Relation = {}
self.TrainTriples = {}
self.RelSub2Obj = {}
... | 10,567 | 51.84 | 119 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/base_data_module.py | """Base DataModule class."""
from pathlib import Path
from typing import Dict
import argparse
import os
import pytorch_lightning as pl
from torch.utils.data import DataLoader
class Config(dict):
def __getattr__(self, name):
return self.get(name)
def __setattr__(self, name, val):
self[name] =... | 2,731 | 28.06383 | 167 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/DataPreprocess.py | import numpy as np
from torch.utils.data import Dataset
import torch
import os
from collections import defaultdict as ddict
from IPython import embed
class KGData(object):
"""Data preprocessing of kg data.
Attributes:
args: Some pre-set parameters, such as dataset path, etc.
ent2id: Encoding... | 17,102 | 34.930672 | 110 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/Sampler.py | from numpy.random.mtrand import normal
import torch
import numpy as np
from torch.utils.data import Dataset
from collections import defaultdict as ddict
import random
from .DataPreprocess import *
from IPython import embed
import dgl
import torch.nn.functional as F
import time
import queue
from os.path import join
imp... | 46,126 | 34.757364 | 278 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/__init__.py | from .Sampler import *
from .KGDataModule import KGDataModule
from .DataPreprocess import *
from .base_data_module import BaseDataModule
from .RuleDataLoader import RuleDataLoader
| 180 | 29.166667 | 44 | py |
NeuralKG | NeuralKG-main/src/neuralkg/data/RuleDataLoader.py | import random
import numpy as np
import torch
from torch.utils.data import Dataset, DataLoader
import os
from collections import defaultdict as ddict
from IPython import embed
class RuleDataset(Dataset):
def __init__(self, args):
self.args = args
self.rule_p, self.rule_q, self.rule_r, self.confide... | 2,474 | 37.671875 | 113 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/__init__.py | from .KGEModel import *
from .GNNModel import *
from .RuleModel import *
| 73 | 17.5 | 24 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/SEGNN.py | import torch
import torch.nn as nn
import dgl
import dgl.function as fn
from neuralkg import utils
from neuralkg.utils.tools import get_param
from neuralkg.model import ConvE
class SEGNN(nn.Module):
def __init__(self, args):
super(SEGNN, self).__init__()
self.device = torch.device("cuda:0")
... | 8,520 | 35.105932 | 132 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/CompGCN.py | import torch
from torch import nn
import dgl
import dgl.function as fn
import torch.nn.functional as F
from neuralkg.model import ConvE
class CompGCN(nn.Module):
"""`Composition-based multi-relational graph convolutional networks`_ (CompGCN),
which jointly embeds both nodes and relations in a relational ... | 10,731 | 41.251969 | 114 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/RGCN.py | import dgl
import torch
import torch.nn as nn
import torch.nn.functional as F
from dgl.nn.pytorch import RelGraphConv
from neuralkg.model import DistMult
class RGCN(nn.Module):
"""`Modeling Relational Data with Graph Convolutional Networks`_ (RGCN), which use GCN framework to model relation data.
Attributes:... | 5,155 | 35.309859 | 124 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/KBAT.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from torch.autograd import Variable
import time
import os
class KBAT(nn.Module):
"""`Learning Attention-based Embeddings for Relation Prediction in Knowledge Graphs`_ (KBAT),
which introduces the attention to aggregate ... | 13,971 | 36.258667 | 109 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/XTransE.py | import torch.nn as nn
import torch
from IPython import embed
from neuralkg.model.KGEModel.model import Model
class XTransE(Model):
"""`Explainable Knowledge Graph Embedding for Link Prediction with Lifestyles in e-Commerce`_ (XTransE), which introduces the attention to aggregate the neighbor node representation.
... | 5,638 | 36.845638 | 248 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/GNNModel/__init__.py | from .RGCN import RGCN
from .KBAT import KBAT
from .CompGCN import CompGCN
from .XTransE import XTransE
from .SEGNN import SEGNN | 128 | 24.8 | 28 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/DistMult.py | import torch.nn as nn
import torch
from .model import Model
from IPython import embed
class DistMult(Model):
"""`Embedding Entities and Relations for Learning and Inference in Knowledge Bases`_ (DistMult)
Attributes:
args: Model configuration parameters.
epsilon: Calculate embedding_range.
... | 3,476 | 34.121212 | 120 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/PairRE.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .model import Model
class PairRE(Model):
"""`PairRE: Knowledge Graph Embeddings via Paired Relation Vectors`_ (PairRE), which paired vectors for each relation representation to model complex patterns.
Attributes:
args: Model confi... | 3,716 | 35.087379 | 163 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/ComplEx.py | import torch.nn as nn
import torch
from .model import Model
from IPython import embed
class ComplEx(Model):
def __init__(self, args):
"""`Complex Embeddings for Simple Link Prediction`_ (ComplEx), which is a simple approach to matrix and tensor factorization for link prediction data that uses vectors with... | 3,926 | 37.5 | 255 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/RotatE.py | import torch.nn as nn
import torch
from .model import Model
from IPython import embed
class RotatE(Model):
"""`RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space`_ (RotatE), which defines each relation as a rotation from the source entity to the target entity in the complex vector space.
... | 4,433 | 36.897436 | 208 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/BoxE.py | import torch.nn as nn
import torch
from torch.autograd import Variable
from .model import Model
class BoxE(Model):
"""`A Box Embedding Model for Knowledge Base Completion`_ (BoxE), which represents the bump embedding as translations in the super rectangle space.
Attributes:
args: Model configurat... | 6,177 | 35.994012 | 151 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/SimplE.py | import torch.nn as nn
import torch
import torch.nn.functional as F
import math
from .model import Model
from IPython import embed
class SimplE(Model):
"""`SimplE Embedding for Link Prediction in Knowledge Graphs`_ (SimpleE), which presents a simple enhancement of CP (which we call SimplE) to allow the two embeddi... | 6,453 | 47.893939 | 212 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/model.py | import torch.nn as nn
import torch
class Model(nn.Module):
def __init__(self, args):
super(Model, self).__init__()
def init_emb(self):
raise NotImplementedError
def score_func(self, head_emb, relation_emb, tail_emb):
raise NotImplementedError
def forward(self, triples, negs,... | 2,572 | 40.5 | 85 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/CrossE.py | import torch.nn as nn
import torch
import torch.nn.functional as F
import math
from .model import Model
from IPython import embed
class CrossE(Model):
"""`Interaction Embeddings for Prediction and Explanation in Knowledge Graphs`_ (CrossE), which simulates crossover interactions(bi-directional effects between ent... | 5,460 | 44.890756 | 187 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/TransR.py | import torch.nn as nn
import torch
import torch.nn.functional as F
from .model import Model
from IPython import embed
class TransR(Model):
"""Learning Entity and Relation Embeddings for Knowledge Graph Completion`_ (TransR), which building entity and relation embeddings in separate entity space and relation space... | 4,844 | 40.410256 | 180 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/DualE.py | import torch.nn as nn
import torch
from .model import Model
from numpy.random import RandomState
import numpy as np
class DualE(Model):
"""`Dual Quaternion Knowledge Graph Embeddings`_ (DualE), which introduces dual quaternions into knowledge graph embeddings.
Attributes:
args: Model configuration pa... | 11,028 | 43.471774 | 131 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/ConvE.py | import torch
import torch.nn as nn
from .model import Model
from IPython import embed
from torch.autograd import Variable
from inspect import stack
#TODO: ConvE and SEGNN
class ConvE(Model):
"""`Convolutional 2D Knowledge Graph Embeddings`_ (ConvE), which use a 2D convolution network for embedding representati... | 5,548 | 36.493243 | 138 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/TransE.py | import torch.nn as nn
import torch
from .model import Model
from IPython import embed
class TransE(Model):
"""`Translating Embeddings for Modeling Multi-relational Data`_ (TransE), which represents the relationships as translations in the embedding space.
Attributes:
args: Model configuration paramet... | 3,488 | 34.969072 | 152 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/__init__.py | from .ComplEx import ComplEx
from .TransE import TransE
from .DistMult import DistMult
from .RotatE import RotatE
from .TransH import TransH
from .TransR import TransR
from .SimplE import SimplE
from .BoxE import BoxE
from .ConvE import ConvE
from .CrossE import CrossE
from .HAKE import HAKE
from .PairRE import PairRE
... | 345 | 23.714286 | 30 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/TransH.py | import torch.nn as nn
import torch
import torch.nn.functional as F
from .model import Model
from IPython import embed
class TransH(Model):
"""`Knowledge Graph Embedding by Translating on Hyperplanes`_ (TransH), which apply the translation from head to tail entity in a
relational-specific hyperplane in order t... | 4,937 | 37.578125 | 133 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/KGEModel/HAKE.py | import torch
import torch.nn as nn
from .model import Model
class HAKE(Model):
"""`Learning Hierarchy-Aware Knowledge Graph Embeddings for Link Prediction`_ (HAKE), which maps entities into the polar coordinate system.
Attributes:
args: Model configuration parameters.
epsilon: Calculate embed... | 5,161 | 35.352113 | 143 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/RuleModel/ComplEx_NNE_AER.py | import torch.nn as nn
import torch
import os
from .model import Model
from IPython import embed
class ComplEx_NNE_AER(Model):
"""`Improving Knowledge Graph Embedding Using Simple Constraints`_ (/ComplEx-NNE_AER), which examines non-negativity constraints on entity representations and approximate entailment constr... | 4,959 | 37.153846 | 226 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/RuleModel/IterE.py | import torch.nn as nn
import torch
import os
from .model import Model
from IPython import embed
from collections import defaultdict
import numpy as np
import pickle
import copy
class IterE(Model):
"""`Iteratively Learning Embeddings and Rules for Knowledge Graph Reasoning. (WWW'19)`_ (IterE).
Attributes:
... | 59,788 | 49.242857 | 265 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/RuleModel/model.py | import torch.nn as nn
import torch
class Model(nn.Module):
def __init__(self, args):
super(Model, self).__init__()
def init_emb(self):
raise NotImplementedError
def score_func(self, head_emb, relation_emb, tail_emb):
raise NotImplementedError
def forward(self, triples, negs,... | 2,572 | 40.5 | 85 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/RuleModel/RugE.py | import torch.nn as nn
import torch
from .model import Model
from IPython import embed
import pdb
class RugE(Model):
"""`Knowledge Graph Embedding with Iterative Guidance from Soft Rules`_ (RugE), which is a novel paradigm of KG embedding with iterative guidance from soft rules.
Attributes:
args: Mode... | 3,796 | 35.161905 | 166 | py |
NeuralKG | NeuralKG-main/src/neuralkg/model/RuleModel/__init__.py | from .ComplEx_NNE_AER import ComplEx_NNE_AER
from .IterE import IterE
from .RugE import RugE
| 93 | 22.5 | 44 | py |
NeuralKG | NeuralKG-main/docs/source/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,913 | 32.113636 | 79 | py |
cmm_ts | cmm_ts-main/main.py | from models.utils import *
from models.AdjLR import AdjLR
from keras.callbacks import ModelCheckpoint, EarlyStopping
from keras.optimizers import Adam
from Data import Data
from keras.layers import *
from keras.models import *
from constants import *
# IAED import
from models.IAED.mIAED import mIAED
from models.IAED.s... | 3,876 | 41.604396 | 160 | py |
cmm_ts | cmm_ts-main/main_bestparams.py | import pickle
from models.utils import *
from keras.optimizers import Adam
from Data import Data
from keras.layers import *
from keras.models import *
from constants import *
import pandas as pd
from kerashypetune import KerasGridSearch
from models.utils import Words as W
# IAED import
from models.IAED.mIAED import mI... | 3,299 | 37.372093 | 140 | py |
cmm_ts | cmm_ts-main/MyParser.py | import argparse
from argparse import RawTextHelpFormatter
from models.utils import *
def print_init(model, targetvar, modeldir, npast, nfuture, ndelay, initdec, train_perc, val_perc, test_perc,
use_att, use_cm, cm, cm_trainable, use_constraint, constraint, batch_size, patience, epochs, lr, adjlr):
... | 6,557 | 50.234375 | 189 | py |
cmm_ts | cmm_ts-main/constants.py | from enum import Enum
import numpy as np
import os
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
RESULT_DIR = ROOT_DIR + "/training_result"
# Parameters definition
N_FEATURES = 8
LIST_FEATURES = ['d_g', 'v', 'risk', 'theta_g', 'omega', 'theta', 'g_seq', 'd_obs']
# MODELS
class Models(Enum):
sIAED = "sIA... | 1,886 | 36 | 105 | py |
cmm_ts | cmm_ts-main/Data.py | from copy import deepcopy
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
import numpy as np
import matplotlib
# matplotlib.use('Qt5Agg')
from matplotlib import pyplot as plt
ALL = 'all'
class Data():
def __init__(self,
data: pd.DataFrame,
n_past: int,
... | 5,701 | 31.033708 | 116 | py |
cmm_ts | cmm_ts-main/load.py | from Data import Data
from constants import RESULT_DIR
# IAED import
from models.IAED.mIAED import mIAED
from models.IAED.sIAED import sIAED
from models.IAED.config import config as cIAED
from models.utils import get_df
N_FUTURE = 48
N_PAST = 32
N_DELAY = 0
TRAIN_PERC = 0.0
VAL_PERC = 0.0
TEST_PERC = 1.0
TEST_AGEN... | 1,027 | 27.555556 | 102 | py |
cmm_ts | cmm_ts-main/models/MyModel.py | from abc import ABC, abstractmethod
import os
from constants import RESULT_DIR
import models.utils as utils
import models.Words as W
from keras.models import *
from matplotlib import pyplot as plt
import pickle
import numpy as np
from tqdm import tqdm
class MyModel(ABC):
def __init__(self, name, df, config : dict... | 15,549 | 40.246684 | 167 | py |
cmm_ts | cmm_ts-main/models/AdjLR.py | import keras
import tensorflow as tf
class AdjLR(keras.callbacks.Callback):
def __init__ (self, model, freq, factor, justOnce, verbose):
self.model = model
self.freq = freq
self.factor = factor
self.justOnce = justOnce
self.verbose = verbose
self.adj_epoch = freq
... | 905 | 38.391304 | 112 | py |
cmm_ts | cmm_ts-main/models/Evaluation.py | from enum import Enum
import numpy as np
class Metric(Enum):
NRMSEmean = {"name": "NRMSE", "value" : "NRMSEmean"}
NRMSEminmax = {"name": "NRMSE", "value" : "NRMSEminmax"}
NRMSEstd = {"name": "NRMSE", "value" : "NRMSEstd"}
NRMSEiq = {"name": "NRMSE", "value" : "NRMSEiq"}
NMAEmean = {"name": "NMAE",... | 1,623 | 29.074074 | 75 | py |
cmm_ts | cmm_ts-main/models/utils.py | import os
import logging
import tensorflow as tf
import absl.logging
from constants import *
import models.Words as Words
import pandas as pd
def init_config(config, folder, npast, nfuture, ndelay, nfeatures, features, initDEC = False,
use_att = False, use_cm = False, cm = None, cm_trainable = False,... | 3,138 | 30.39 | 125 | py |
cmm_ts | cmm_ts-main/models/Words.py | FOLDER = "FOLDER"
NPAST = "NPAST"
NFUTURE = "NFUTURE"
NDELAY = "NDELAY"
NFEATURES = "NFEATURES"
FEATURES = "FEATURES"
USEATT = "USEATT"
USECAUSAL = "USECAUSAL"
CMATRIX = "CMATRIX"
CTRAINABLE = "CTRAINABLE"
USECONSTRAINT = "USECONSTRAINT"
TRAINTHRESH = "TRAINTHRESH"
ATTUNITS = "ATTUNITS"
ENCDECUNITS = "ENCDECUNITS"
DECI... | 388 | 19.473684 | 31 | py |
cmm_ts | cmm_ts-main/models/DenseDropout.py | from keras.layers import *
from keras.models import *
class DenseDropout(Layer):
def __init__(self, units, activation, dropout):
super(DenseDropout, self).__init__()
self.dbit = dropout != 0
self.dense = Dense(units, activation = activation)
if self.dbit: self.dropout = Dropout(dro... | 437 | 23.333333 | 58 | py |
cmm_ts | cmm_ts-main/models/Constraints.py | from keras.constraints import Constraint
import keras.backend as K
import numpy as np
class Between(Constraint):
def __init__(self, init_value, adj_thres):
self.adj_thres = adj_thres
# self.min_value = init_value - self.adj_thres
self.max_value = init_value + self.adj_thres
self.min... | 1,019 | 24.5 | 79 | py |
cmm_ts | cmm_ts-main/models/IAED/IAED2.py | import numpy as np
from constants import CM_FPCMCI
from models.attention.SelfAttention import SelfAttention
from models.attention.InputAttention import InputAttention
from keras.layers import *
from keras.models import *
import tensorflow as tf
import models.Words as W
from models.DenseDropout import DenseDropout
clas... | 5,627 | 44.756098 | 150 | py |
cmm_ts | cmm_ts-main/models/IAED/config.py | from models.utils import Words as W
config = {
W.FOLDER : None,
W.NPAST : None,
W.NFUTURE : None,
W.NDELAY : None,
W.NFEATURES : None,
W.FEATURES : None,
W.USEATT : False,
W.USECAUSAL : False,
W.CTRAINABLE : None,
W.USECONSTRAINT : False,
W.TRAINTHRESH : None,
W.ATTUNIT... | 416 | 18.857143 | 35 | py |
cmm_ts | cmm_ts-main/models/IAED/IAED.py | from matplotlib.pyplot import yscale
import numpy as np
from constants import CM_FPCMCI
from models.attention.SelfAttention import SelfAttention
from models.attention.InputAttention import InputAttention
from keras.layers import *
from keras.models import *
import tensorflow as tf
import models.Words as W
from models.D... | 4,444 | 40.542056 | 150 | py |
cmm_ts | cmm_ts-main/models/IAED/mIAED.py | from keras.layers import *
from keras.models import *
from keras.utils.vis_utils import plot_model
from constants import LIST_FEATURES
from models.MyModel import MyModel
from .IAED import IAED
from models.utils import Models
import models.Words as W
class mIAED(MyModel):
def __init__(self, df, config : dict = No... | 1,267 | 36.294118 | 145 | py |
cmm_ts | cmm_ts-main/models/IAED/sIAED.py | from keras.layers import *
from keras.models import *
from keras.utils.vis_utils import plot_model
from models.utils import Models
from models.MyModel import MyModel
from .IAED2 import IAED
import models.Words as W
class sIAED(MyModel):
def __init__(self, df, config : dict = None, folder : str = None):
su... | 1,051 | 39.461538 | 145 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.