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
Squeezeformer
Squeezeformer-main/src/utils/file_util.py
# Copyright 2020 Huy Le Nguyen (@usimarit) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed t...
3,440
33.41
110
py
Squeezeformer
Squeezeformer-main/src/utils/layer_util.py
# Copyright 2020 Huy Le Nguyen (@usimarit) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed ...
1,002
32.433333
74
py
Squeezeformer
Squeezeformer-main/src/utils/training_utils.py
import tensorflow as tf from tensorflow.python.keras import backend from tensorflow.python.framework import sparse_tensor from tensorflow.python.framework import ops from tensorflow.python.eager import context from tensorflow.python.util import nest from tensorflow.python.ops import variables from tensorflow.python.op...
3,574
37.44086
97
py
Squeezeformer
Squeezeformer-main/src/utils/logging_util.py
import wandb import tensorflow as tf import numpy as np from numpy import linalg as la from . import env_util logger = env_util.setup_environment() class StepLossMetric(tf.keras.metrics.Metric): def __init__(self, name='step_loss', **kwargs): super(StepLossMetric, self).__init__(name=name, **kwargs) ...
1,090
24.97619
79
py
Squeezeformer
Squeezeformer-main/src/losses/ctc_loss.py
# Copyright 2020 Huy Le Nguyen (@usimarit) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed t...
1,560
34.477273
90
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='xnchen2020@zju.edu.cn', 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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
cmm_ts
cmm_ts-main/models/attention/InputAttention.py
import tensorflow as tf import keras.backend as K from keras.layers import * class InputAttention(Layer): def __init__(self, config, name = 'Attention'): super(InputAttention, self).__init__(name = name) self.config = config def build(self, inputs): # input_shape = batch x n_past x n...
1,990
31.639344
102
py
cmm_ts
cmm_ts-main/models/attention/SelfAttention.py
import tensorflow as tf import numpy as np from keras.layers import * from models.Constraints import * import models.Words as W import keras.backend as K class SelfAttention(Layer): def __init__(self, config, causal_vec : np.array, name = 'Attention'): super(SelfAttention, self).__init__(name = name) ...
1,508
38.710526
93
py
TreEnhance
TreEnhance-master/ptcolor.py
"""Pytorch routines for color conversions and management. All color arguments are given as 4-dimensional tensors representing batch of images (Bx3xHxW). RGB values are supposed to be in the range 0-1 (but values outside the range are tolerated). Some examples: >>> rgb = torch.tensor([0.8, 0.4, 0.2]).view(1, 3, 1, 1...
11,528
28.561538
113
py
TreEnhance
TreEnhance-master/data_Prep.py
import torch import torch.utils import torch.utils.data import os from torchvision import transforms from random import random, sample from PIL import Image class Dataset_LOL(torch.utils.data.Dataset): def __init__(self, raw_dir, exp_dir, subset_img=None, size=None, training=True): self.raw_dir = raw_dir ...
1,956
32.169492
89
py
TreEnhance
TreEnhance-master/training.py
#!/usr/bin/env python3 import torch import torch.utils import torch.utils.data from torch.utils.tensorboard import SummaryWriter import collections import numpy as np import random from data_Prep import LoadDataset, Dataset_LOL import Actions as Actions import warnings import Network import os from matplotlib import py...
11,048
36.327703
118
py
TreEnhance
TreEnhance-master/Actions.py
import torch import torch.utils import torch.utils.data from ColorAlgorithms import Gray_World, MaxRGB, saturation, hue from torchvision import transforms from PIL import ImageFilter def select(img, act): if act == 0: return gamma_corr(img, 0.6, 0) elif act == 1: return gamma_corr(img, 0.6, 1)...
3,418
27.491667
119
py
TreEnhance
TreEnhance-master/Network.py
import torch from torchvision.models import resnet18 import torch.nn as nn class ModifiedResnet(nn.Module): def __init__(self, n_actions, Dropout=None): super(ModifiedResnet, self).__init__() self.model = resnet18(pretrained=False) num_ftrs = self.model.fc.in_features self.model.fc...
879
34.2
119
py
TreEnhance
TreEnhance-master/metrics.py
import torch def PSNR(img, gt): mseL = torch.nn.MSELoss() mse = mseL(img, gt) if mse != 0: print(20 * torch.log10(1 / torch.sqrt(mse))) return 20 * torch.log10(1 / torch.sqrt(mse)) return 20 * torch.log10(1 / torch.sqrt(torch.tensor(1e-9)))
275
24.090909
63
py
TreEnhance
TreEnhance-master/evaluation.py
#!/usr/bin/env python3 import warnings import torch import torch.utils import torch.utils.data import numpy as np from data_Prep import Dataset_LOL import Actions as Actions import Network import tqdm import mcts import argparse from ptcolor import deltaE94, rgb2lab warnings.filterwarnings("ignore") NUM_ACTIONS = 37 M...
5,424
30.358382
94
py
TreEnhance
TreEnhance-master/ColorAlgorithms.py
import torch from torchvision.transforms.functional import adjust_saturation, adjust_hue def Gray_World(img): m = img.mean(-2, True).mean(-1, True) img = img / torch.clamp(m, min=1e-3) ma = img.max(-1, True).values.max(-2, True).values.max(-3, True).values return img / torch.clamp(ma, min=1e-3) def ...
584
24.434783
77
py
deep-viz-keras
deep-viz-keras-master/saliency.py
# Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
2,836
35.371795
93
py
deep-viz-keras
deep-viz-keras-master/guided_backprop.py
# Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
3,669
42.176471
106
py
deep-viz-keras
deep-viz-keras-master/visual_backprop.py
from saliency import SaliencyMask import numpy as np import keras.backend as K from keras.layers import Input, Conv2DTranspose from keras.models import Model from keras.initializers import Ones, Zeros class VisualBackprop(SaliencyMask): """A SaliencyMask class that computes saliency masks with VisualBackprop (http...
2,406
40.5
112
py
lrec2020-coref
lrec2020-coref-master/scripts/bert_coref.py
import re import os from collections import Counter import sys import argparse import pytorch_pretrained_bert from pytorch_pretrained_bert.modeling import BertPreTrainedModel, BertModel, BertConfig from pytorch_pretrained_bert import BertTokenizer from pytorch_pretrained_bert.file_utils import PYTORCH_PRETRAINED_BERT_...
24,602
24.233846
255
py
CGMM
CGMM-master/score.py
from typing import List import torch from pydgn.training.callback.metric import Metric class CGMMCompleteLikelihoodScore(Metric): @property def name(self) -> str: return 'Complete Log Likelihood' def __init__(self, use_as_loss=False, reduction='mean', use_nodes_batch_size=True): super()...
2,750
36.175676
114
py
CGMM
CGMM-master/cgmm_embedding_task.py
import os import shutil import torch from cgmm_incremental_task import CGMMTask # This works with graph classification only from pydgn.static import LOSS, SCORE class EmbeddingCGMMTask(CGMMTask): def run_valid(self, dataset_getter, logger): """ This function returns the training and validation...
7,955
53.122449
162
py
CGMM
CGMM-master/emission.py
import math import scipy import scipy.cluster import scipy.cluster.vq import torch # Interface for all emission distributions from torch.nn import ModuleList class EmissionDistribution(torch.nn.Module): def __init__(self): super().__init__() def init_accumulators(self): raise NotImplementedE...
22,661
40.734807
120
py
CGMM
CGMM-master/readout.py
import torch from pydgn.model.interface import ReadoutInterface class CGMMGraphReadout(ReadoutInterface): def __init__(self, dim_node_features, dim_edge_features, dim_target, config): super().__init__(dim_node_features, dim_edge_features, dim_target, config) embeddings_node_features = dim_node_f...
641
32.789474
82
py
CGMM
CGMM-master/cgmm.py
import torch from pydgn.model.interface import ModelInterface from util import compute_bigram, compute_unigram from torch_geometric.nn import global_mean_pool, global_add_pool from torch_scatter import scatter_add, scatter_max class CGMM(ModelInterface): def __init__(self, dim_node_features, dim_edge_features, ...
22,943
43.638132
120
py
CGMM
CGMM-master/probabilistic_readout.py
from typing import Tuple, Optional, List import torch from pydgn.experiment.util import s2c class ProbabilisticReadout(torch.nn.Module): def __init__(self, dim_node_features, dim_edge_features, dim_target, config): super().__init__() self.K = dim_node_features self.Y = dim_target ...
3,817
33.396396
82
py
CGMM
CGMM-master/cgmm_incremental_task.py
import os import shutil import torch from pydgn.experiment.experiment import Experiment from pydgn.experiment.util import s2c from pydgn.static import LOSS, SCORE from torch.utils.data.sampler import SequentialSampler from torch_geometric.data import Data class CGMMTask(Experiment): def __init__(self, model_con...
25,222
54.557269
240
py
CGMM
CGMM-master/util.py
from typing import Optional, Tuple, List import torch import torch_geometric def extend_lists(data_list: Optional[Tuple[Optional[List[torch.Tensor]]]], new_data_list: Tuple[Optional[List[torch.Tensor]]]) -> Tuple[Optional[List[torch.Tensor]]]: r""" Extends the semantic of Python :func:`exten...
8,585
41.50495
160
py
CGMM
CGMM-master/incremental_engine.py
import torch from pydgn.training.engine import TrainingEngine from util import extend_lists, to_tensor_lists class IncrementalTrainingEngine(TrainingEngine): def __init__(self, engine_callback, model, loss, **kwargs): super().__init__(engine_callback, model, loss, **kwargs) def _to_list(self, data_li...
838
40.95
104
py
CGMM
CGMM-master/cgmm_classifier_task.py
import os import torch from cgmm_incremental_task import CGMMTask from pydgn.experiment.util import s2c from pydgn.static import LOSS, SCORE from torch_geometric.data import Data from torch_geometric.loader import DataLoader # This works with graph classification only class ClassifierCGMMTask(CGMMTask): def run...
9,149
55.481481
146
py
CGMM
CGMM-master/provider.py
import random import numpy as np from pydgn.data.dataset import ZipDataset from pydgn.data.provider import DataProvider from pydgn.data.sampler import RandomSampler from torch.utils.data import Subset def seed_worker(exp_seed, worker_id): np.random.seed(exp_seed + worker_id) random.seed(exp_seed + worker_id)...
2,201
37.631579
118
py
BVQI
BVQI-master/temporal_naturalness.py
import torch import argparse import pickle as pkl import numpy as np import math import torch import torch.nn.functional as F import yaml from scipy.stats import pearsonr, spearmanr from scipy.stats import kendalltau as kendallr from tqdm import tqdm from sklearn import decomposition import time from buona_vista imp...
4,901
30.625806
96
py
BVQI
BVQI-master/semantic_affinity.py
## Contributed by Teo Haoning Wu, Daniel Annan Wang import argparse import pickle as pkl import open_clip import numpy as np import torch import yaml from scipy.stats import pearsonr, spearmanr from scipy.stats import kendalltau as kendallr from tqdm import tqdm from buona_vista import datasets def rescale(x): ...
3,856
30.614754
96
py
BVQI
BVQI-master/spatial_naturalness.py
# Contributed by Teo Haoning Wu, Erli Zhang Karl import argparse import glob import math import os import pickle as pkl from collections import OrderedDict import decord import numpy as np import torch import torchvision as tv import yaml from pyiqa import create_metric from pyiqa.default_model_configs import DEFAULT...
3,380
28.657895
88
py