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
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/mutation_options.py
import argparse import numpy as np import random import copy import tequila as tq from typing import Union from collections import Counter from time import time from vqe_utils import convert_PQH_to_tq_QH, convert_tq_QH_to_PQH,\ fold_unitary_into_hamiltonian from energy_optimization import minimi...
26,780
33.962141
191
py
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/hacked_openfermion_qubit_operator.py
import tequila as tq import sympy import copy #from param_hamiltonian import get_geometry, generate_ucc_ansatz from hacked_openfermion_symbolic_operator import SymbolicOperator # Define products of all Pauli operators for symbolic multiplication. _PAULI_OPERATOR_PRODUCTS = { ('I', 'I'): (1., 'I'), ('I', 'X')...
9,918
29.614198
85
py
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/HEA.py
import tequila as tq import numpy as np from tequila import gates as tq_g from tequila.objective.objective import Variable def generate_HEA(num_qubits, circuit_id=11, num_layers=1): """ This function generates different types of hardware efficient circuits as in this paper https://onlinelibrary.wiley....
18,425
45.530303
172
py
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/grad_hacked.py
from tequila.circuit.compiler import CircuitCompiler from tequila.objective.objective import Objective, ExpectationValueImpl, Variable, \ assign_variable, identity, FixedVariable from tequila import TequilaException from tequila.objective import QTensor from tequila.simulators.simulator_api import compile import ty...
9,886
38.548
132
py
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/vqe_utils.py
import tequila as tq import numpy as np from hacked_openfermion_qubit_operator import ParamQubitHamiltonian from openfermion import QubitOperator from HEA import * def get_ansatz_circuit(ansatz_type, geometry, basis_set=None, trotter_steps = 1, name=None, circuit_id=None,num_layers=1): """ This function gene...
27,934
51.807183
162
py
partitioning-with-cliffords
partitioning-with-cliffords-main/data/n2/n2_serial_bl_2.25/hacked_openfermion_symbolic_operator.py
import abc import copy import itertools import re import warnings import sympy import tequila as tq from tequila.objective.objective import Objective, Variable from openfermion.config import EQ_TOLERANCE COEFFICIENT_TYPES = (int, float, complex, sympy.Expr, Variable, Objective) class SymbolicOperator(metaclass=ab...
25,797
35.697013
97
py
pyIFD
pyIFD-main/test_pyifd.py
from tests.validate_algo import validate_algo def test_adq1(): assert validate_algo('tests/data/168_image.jpg', 'tests/data/168_ADQ1.mat', 'ADQ1', 0.9) is True def test_adq2(): assert validate_algo('tests/data/168_image.jpg', 'tests/data/168_ADQ2.mat', 'ADQ2', 0.9) is True def test_adq3(): assert vali...
1,836
28.629032
101
py
pyIFD
pyIFD-main/setup.py
from setuptools import find_packages, setup setup( name='pyIFD', version='0.0.2', extras_require=dict(tests=['pytest']), packages=find_packages(where="src"), package_dir={"": "src"}, include_package_data=True, setup_requires=[ 'cython','numpy'], install_requires=[ 'cytho...
489
20.304348
43
py
pyIFD
pyIFD-main/src/__init__.py
0
0
0
py
pyIFD
pyIFD-main/src/pyIFD/BLK.py
""" This module provides the BLK algorithm JPEG-block-artifact-based detector, solution 1. Algorithm attribution: Li, Weihai, Yuan Yuan, and Nenghai Yu. "Passive detection of doctored JPEG image via block artifact grid extraction." Signal Processing 89, no. 9 (2009): 1821-1829. Based on code from: Zampoglou, M., Pap...
5,382
31.823171
187
py
pyIFD
pyIFD-main/src/pyIFD/CAGI.py
""" This module provides the CAGI algorithm JPEG-grid-alignment-abnormality-based detector. Algorithm attribution: Iakovidou, Chryssanthi, Markos Zampoglou, Symeon Papadopoulos, and Yiannis Kompatsiaris. "Content-aware detection of JPEG grid inconsistencies for intuitive image forensics." Journal of Visual Communicat...
28,116
28.411088
251
py
pyIFD
pyIFD-main/src/pyIFD/GHOST.py
""" This module provides the GHOST algorithm JPEG-block-artifact-based detector, solution 3 (leveraging JPEG ghosts). Algorithm attribution: Farid, Hany. "Exposing digital forgeries from JPEG ghosts." Information Forensics and Security, IEEE Transactions on 4, no. 1 (2009): 154-160. Based on code from: Zampoglou, M....
3,318
37.593023
187
py
pyIFD
pyIFD-main/src/pyIFD/NOI5.py
""" This module provides the NOI5 algorithm Noise-variance-inconsistency detector, solution 5 (leveraging Principal Component Analysis). Algorithm attribution: H. Zeng, Y. Zhan, X. Kang, X. Lin, Image splicing localization using PCA-based noise level estimation, Multimedia Tools & Applications, 2017.76(4):4783 http:/...
13,151
33.25
187
py
pyIFD
pyIFD-main/src/pyIFD/NADQ.py
""" This module provides the NADQ algorithm Aligned- and Non-aligned-double-JPEG-compression-based detector. Algorithm attribution: T.Bianchi, A.Piva, "Image Forgery Localization via Block-Grained Analysis of JPEG Artifacts", IEEE Transactions on Information Forensics & Security, vol. 7, no. 3, June 2012, pp. 100...
13,218
36.028011
187
py
pyIFD
pyIFD-main/src/pyIFD/DCT.py
""" This module provides the DCT algorithm JPEG-block-artifact-based detector, solution 2 (leveraging Discrete Cosine Transforms). Algorithm attribution: Ye, Shuiming, Qibin Sun, and Ee-Chien Chang. "Detecting digital image forgeries by measuring inconsistencies of blocking artifact." In Multimedia and Expo, 2007 IEE...
4,867
31.891892
187
py
pyIFD
pyIFD-main/src/pyIFD/NOI2.py
""" This module provides the NOI2 algorithm Noise-variance-inconsistency detector, solution 2. Algorithm attribution: Lyu, Siwei, Xunyu Pan, and Xing Zhang. "Exposing region splicing forgeries with blind local noise estimation." International Journal of Computer Vision 110, no. 2 (2014): 202-221. Based on code from:...
8,753
27.891089
187
py
pyIFD
pyIFD-main/src/pyIFD/NOI1.py
""" This module provides the NOI1 algorithm Noise-variance-inconsistency detector, solution 1. Algorithm attribution: Mahdian, Babak, and Stanislav Saic. "Using noise inconsistencies for blind image forensics." Image and Vision Computing 27, no. 10 (2009): 1497-1503. Based on code from: Zampoglou, M., Papadopoulos, ...
1,717
33.36
187
py
pyIFD
pyIFD-main/src/pyIFD/ADQ1.py
""" This module provides the ADQ1 module. Aligned-double-JPEG-compression-based detector, solution 1. Algorithm attribution: Lin, Zhouchen, Junfeng He, Xiaoou Tang, and Chi-Keung Tang. "Fast, automatic and fine-grained tampered JPEG image detection via DCT coefficient analysis." Pattern Recognition 42, no. 11 (2009):...
14,409
39.706215
187
py
pyIFD
pyIFD-main/src/pyIFD/ELA.py
""" This module provides the ELA algorithm Error-level-analysis-based detector. Algorithm attribution: Krawets, Neil. "A Picture's Worth: Digital Image Analysis and Forensics". Online article on http://www.google.gr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiDg5_c07PLAhVpnXIKHUp8B5QQFgggMAA&u...
1,647
36.454545
273
py
pyIFD
pyIFD-main/src/pyIFD/util.py
""" This file provides utility functions for pyIFD modules. """ import numpy as np import math import cv2 from scipy import signal def minmaxpercent(o, p=0.05): o = o[np.isfinite(o)] a = 0 b = 0 p=0.01 if o.size==0: a=0 b=1 else: o = np.sort(o) a = o[int(max(np....
8,099
29.451128
164
py
pyIFD
pyIFD-main/src/pyIFD/CFA2.py
""" This module provides the CFA2 algorithm Color-filter-array-artifact-based detector, solution 2. Algorithm attribution: Dirik, Ahmet Emir, and Nasir D. Memon. "Image tamper detection based on demosaicing artifacts." In ICIP, pp. 1497-1500. 2009. Based on code from: Zampoglou, M., Papadopoulos, S., & Kompatsiaris,...
6,932
36.679348
187
py
pyIFD
pyIFD-main/src/pyIFD/ADQ2.py
""" This module provides the ADQ2 Algorithm Aligned-double-JPEG-compression-based detector, solution 2. Algorithm attribution: T. Bianchi, A. De Rosa, and A. Piva, "IMPROVED DCT COEFFICIENT ANALYSIS FOR FORGERY LOCALIZATION IN JPEG IMAGES", ICASSP 2011, Prague, Czech Republic, 2011, pp. 2444-2447. Based on code from...
11,148
34.733974
191
py
pyIFD
pyIFD-main/src/pyIFD/CFA1.py
""" This module provides the CFA1 Algorithm Color-filter-array-artifact-based detector, solution 1. Algorithm attribution: P. Ferrara, T. Bianchi, A. De Rosa and P. Piva, "Image Forgery Localization via Fine-Grained Analysis of CFA Artifacts", IEEE Transactions on Information Forensics & Security, vol. 7, no. 5, Oc...
7,738
28.765385
187
py
pyIFD
pyIFD-main/src/pyIFD/__init__.py
0
0
0
py
pyIFD
pyIFD-main/src/pyIFD/ADQ3.py
""" This module provides the ADQ3 algorithm Aligned-double-JPEG-compression-based detector, solution 3. Algorithm attribution: Amerini, Irene, Rudy Becarelli, Roberto Caldelli, and Andrea Del Mastio. "Splicing forgeries localization through the use of first digit features." In Information Forensics and Security (WIFS...
5,636
37.609589
187
py
pyIFD
pyIFD-main/src/pyIFD/NOI4.py
""" This module provides the NOI4 algorithm Noise-variance-inconsistency detector, solution 4 (leveraging median filters). Algorith attribution: https://29a.ch/2015/08/21/noise-analysis-for-image-forensics Based on code from: Zampoglou, M., Papadopoulos, S., & Kompatsiaris, Y. (2017). Large-scale evaluation of splic...
1,286
27.6
187
py
pyIFD
pyIFD-main/tests/validate_algo.py
from pyIFD.ADQ1 import detectDQ from pyIFD.ADQ2 import getJmap from pyIFD.ADQ3 import BenfordDQ from pyIFD.BLK import GetBlockGrid from pyIFD.CAGI import CAGI from pyIFD.CFA1 import CFA1 from pyIFD.CFA2 import CFA2 from pyIFD.DCT import DCT from pyIFD.ELA import ELA from pyIFD.GHOST import GHOST from pyIFD.NADQ import ...
12,335
29.309582
196
py
mt3
mt3-main/setup.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
2,153
30.676471
74
py
mt3
mt3-main/mt3/inference.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
4,386
30.561151
76
py
mt3
mt3-main/mt3/vocabularies_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
4,164
35.217391
80
py
mt3
mt3-main/mt3/run_length_encoding_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
3,362
30.138889
75
py
mt3
mt3-main/mt3/spectral_ops.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
2,845
30.977528
78
py
mt3
mt3-main/mt3/network.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
13,894
32.890244
80
py
mt3
mt3-main/mt3/mixing.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
3,396
35.923913
80
py
mt3
mt3-main/mt3/metrics_utils.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
7,437
36.756345
82
py
mt3
mt3-main/mt3/spectrograms.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
2,330
27.084337
74
py
mt3
mt3-main/mt3/layers.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
32,586
38.2142
157
py
mt3
mt3-main/mt3/run_length_encoding.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
15,922
36.554245
93
py
mt3
mt3-main/mt3/metrics_utils_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
8,271
30.815385
80
py
mt3
mt3-main/mt3/event_codec_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
1,803
31.214286
74
py
mt3
mt3-main/mt3/version.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
622
35.647059
74
py
mt3
mt3-main/mt3/note_sequences.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
17,423
37.979866
90
py
mt3
mt3-main/mt3/datasets.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
14,018
42.003067
127
py
mt3
mt3-main/mt3/vocabularies.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
9,175
31.424028
80
py
mt3
mt3-main/mt3/layers_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
21,675
38.699634
81
py
mt3
mt3-main/mt3/models.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
5,990
38.156863
80
py
mt3
mt3-main/mt3/metrics.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
15,414
38.223919
80
py
mt3
mt3-main/mt3/__init__.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
1,052
29.970588
74
py
mt3
mt3-main/mt3/summaries.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
18,358
37.896186
80
py
mt3
mt3-main/mt3/tasks.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
14,610
35.255583
80
py
mt3
mt3-main/mt3/note_sequences_test.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
19,150
36.847826
103
py
mt3
mt3-main/mt3/preprocessors.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
23,632
34.273134
80
py
mt3
mt3-main/mt3/event_codec.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
3,898
33.504425
80
py
mt3
mt3-main/mt3/scripts/extract_monophonic_examples.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
8,754
33.742063
80
py
mt3
mt3-main/mt3/scripts/dump_task.py
# Copyright 2023 The MT3 Authors. # # 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 to in writ...
2,485
29.691358
79
py
FairAC
FairAC-main/src/utils.py
#%% import numpy as np import scipy.sparse as sp import torch import os import pandas as pd import dgl def encode_onehot(labels): classes = set(labels) classes_dict = {c: np.identity(len(classes))[i, :] for i, c in enumerate(classes)} labels_onehot = np.array(list(map(classes_dict.get, l...
8,676
33.84739
135
py
FairAC
FairAC-main/src/train_fairAC_GNN_report.py
import time import argparse import dgl import numpy as np from sklearn.model_selection import train_test_split import torch import torch.nn.functional as F from utils import accuracy, load_pokec from models.FairAC import FairAC2, GNN def parser_args(): # Training settings parser = argparse.ArgumentParser() ...
21,680
50.376777
162
py
FairAC
FairAC-main/src/models/HGNN_AC.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class HGNN_AC(nn.Module): def __init__(self, in_dim, hidden_dim, dropout, activation, num_heads, cuda=False): super(HGNN_AC, self).__init__() self.dropout = dropout self.attentions = [AttentionLayer(in_di...
2,074
38.903846
115
py
FairAC
FairAC-main/src/models/GCN.py
import torch.nn as nn import torch.nn.functional as F from dgl.nn.pytorch import GraphConv class GCN(nn.Module): def __init__(self, nfeat, nhid, nclass, dropout): super(GCN, self).__init__() self.body = GCN_Body(nfeat,nhid,dropout) self.fc = nn.Linear(nhid,nclass) def forward(self, g, ...
830
22.742857
53
py
FairAC
FairAC-main/src/models/FairGNN.py
import random import torch.nn as nn from .GCN import GCN,GCN_Body from .GAT import GAT,GAT_body from .SAGE import SAGE_Body from .HGNN_AC import HGNN_AC import torch import torch.nn.functional as F import numpy as np def get_model(nfeat, args): if args.model == "GCN": model = GCN_Body(nfeat,args.num_hidd...
10,512
39.279693
159
py
FairAC
FairAC-main/src/models/FairAC.py
import random import torch.nn as nn from .GCN import GCN,GCN_Body from .GAT import GAT,GAT_body from .SAGE import SAGE_Body from .HGNN_AC import HGNN_AC import torch import torch.nn.functional as F import numpy as np def get_model(nfeat, args): if args.model == "GCN": model = GCN_Body(nfeat,args.num_hidd...
6,883
40.97561
131
py
FairAC
FairAC-main/src/models/SAGE.py
import torch.nn as nn import torch.nn.functional as F from dgl.nn.pytorch import SAGEConv class SAGE(nn.Module): def __init__(self, nfeat, nhid, nclass, dropout): super(SAGE, self).__init__() self.body = SAGE_Body(nfeat,nhid,dropout) self.fc = nn.Linear(nhid,nclass) def forward(self, g...
848
23.257143
53
py
FairAC
FairAC-main/src/models/__init__.py
from .GCN import * from .GAT import * from .HGNN_AC import * from .FairGNN import * from .SAGE import *
103
19.8
22
py
FairAC
FairAC-main/src/models/GAT.py
import torch.nn as nn import torch.nn.functional as F from dgl.nn.pytorch import GATConv class GAT_body(nn.Module): def __init__(self, num_layers, in_dim, num_hidden, heads, feat_drop, attn_drop, ...
2,108
33.57377
115
py
Pinyin2Hanzi
Pinyin2Hanzi-master/setup.py
# -*- coding: utf-8 -*- from distutils.core import setup LONGDOC = """ Engine of Chinese Input Method. Please go to https://github.com/someus/Pinyin2Hanzi for more info. 具体使用请移步 https://github.com/someus/Pinyin2Hanzi 。 """ setup( name='Pinyin2Hanzi', version='0.1.1', description='拼音转汉字, Engine of Chinese...
1,164
31.361111
66
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/dag.py
# coding: utf-8 from __future__ import (print_function, unicode_literals, absolute_import) from .interface import AbstractDagParams from .priorityset import PrioritySet from .util import xrange import math def dag(dag_params, pinyin_list, path_num=6, log=False): assert( isinstance(dag_params, AbstractDagParams) ...
1,575
27.654545
85
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/implement.py
# coding: utf-8 from __future__ import (print_function, unicode_literals, absolute_import) from .interface import AbstractHmmParams, AbstractDagParams from .util import as_text import os import json DATA = 'data' DEFAULT = 'default' class DefaultHmmParams(AbstractHmmParams): def __init__(self,): cur...
3,400
27.341667
102
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/priorityset.py
# coding: utf-8 import heapq class Item(object): def __init__(self, score, path): self.__score = score self.__path = path @property def score(self): return self.__score @property def path(self): return self.__path def __lt__(self, other): return sel...
1,553
20.583333
74
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/viterbi.py
# coding: utf-8 from __future__ import (print_function, unicode_literals, absolute_import) from .interface import AbstractHmmParams from .priorityset import PrioritySet import math def viterbi(hmm_params, observations, path_num=6, log=False, min_prob=3.14e-200): assert( isinstance(hmm_params, AbstractHmmParams) ...
2,243
33.523077
85
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/util.py
# coding: utf-8 from __future__ import (print_function, unicode_literals, absolute_import) import os import sys try: reload(sys) sys.setdefaultencoding('utf-8') except: pass PY2 = sys.version_info[0] == 2 if not PY2: # Python 3.x and up xrange = range def as_text(v): ## 生成unicode字符串 ...
6,251
30.736041
114
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/__init__.py
from __future__ import absolute_import from .interface import AbstractHmmParams, AbstractDagParams from .implement import DefaultHmmParams, DefaultDagParams from .priorityset import Item, PrioritySet from .util import is_chinese, remove_tone, normlize_pinyin, simplify_pinyin, is_pinyin, all_pinyin from .dag import d...
351
34.2
98
py
Pinyin2Hanzi
Pinyin2Hanzi-master/Pinyin2Hanzi/interface.py
# coding: utf-8 class AbstractHmmParams(object): def start(self, state): ''' get start prob of state(hanzi) ''' pass def emission(self, state, observation): ''' state (hanzi) -> observation (pinyin) ''' pass def transition(self, from_state, to_state): ''' stat...
547
21.833333
54
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/dag/gen_phrase.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys import json sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util from ChineseTone import PinyinHelper, PinyinFormat import jieba def cut(s): return jieba.cut(s, cut_all=False) def writejson2file(obj, filename): w...
2,024
27.125
77
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/dag/gen_finally.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys import json sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util def writejson2file(obj, filename): with open(filename, 'w') as outfile: data = json.dumps(obj, indent=4, sort_keys=True) outfile.write(d...
2,429
26.931034
89
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/dag/gen_char.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys import json sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util pinyin2hanzi_file = '../hmm/result/pinyin2hanzi.txt' base_emission_file = '../hmm/result/base_emission.json' output_file = './result/dag_char.json' def w...
1,904
24.065789
66
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/hmm/process_article.py
# coding: utf-8 ''' 从文章中提取句子,放到sentence.txt中 ''' from __future__ import (print_function, unicode_literals) import os import sys import json import pypinyin import argparse sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util try: reload(sys) sys.setdefaultencoding('utf-8') except: pass ARTICL...
1,822
20.963855
63
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/hmm/process_finally.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import os import sys import json sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util try: reload(sys) sys.setdefaultencoding('utf-8') except: pass BASE_START_FILE = './result/base_start.json' BASE_EMISSION_FILE ...
3,619
26.218045
93
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/hmm/gen_base.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import os import sys import json from ChineseTone import PinyinHelper import argparse sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util try: reload(sys) sys.setdefaultencoding('utf-8') except: pass SENTENCE_FILE ...
4,871
25.193548
123
py
Pinyin2Hanzi
Pinyin2Hanzi-master/train/hmm/process_hzpy.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import os import sys sys.path = ['../..'] + sys.path from Pinyin2Hanzi import util try: reload(sys) sys.setdefaultencoding('utf-8') except: pass SOURCE_FILE = './hanzipinyin.txt' ALL_STATES_FILE = './result/all_s...
1,399
22.728814
89
py
Pinyin2Hanzi
Pinyin2Hanzi-master/example/pinyin_list.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys sys.path.append('..') from Pinyin2Hanzi import all_pinyin from Pinyin2Hanzi import DefaultDagParams dagparams = DefaultDagParams() for py in all_pinyin(): if len(dagparams.get_phrase([py]) ) == 0: print(py) print( dag...
387
19.421053
57
py
Pinyin2Hanzi
Pinyin2Hanzi-master/example/viterbi_health_fever.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys sys.path.append('..') from Pinyin2Hanzi import AbstractHmmParams from Pinyin2Hanzi import viterbi class HmmParams(AbstractHmmParams): def __init__(self,): self.states = ('Healthy', 'Fever') self.observations =...
2,383
29.177215
110
py
Pinyin2Hanzi
Pinyin2Hanzi-master/example/viterbi_pinyin2hanzi.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys sys.path.append('..') from Pinyin2Hanzi import DefaultHmmParams from Pinyin2Hanzi import viterbi hmmparams = DefaultHmmParams() result = viterbi(hmm_params=hmmparams, observations=('ni', 'hao', 'a'), path_num = 5, log = True) for i...
2,026
27.957143
114
py
Pinyin2Hanzi
Pinyin2Hanzi-master/example/dag_pinyin2hanzi_2.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys sys.path.append('..') from Pinyin2Hanzi import DefaultDagParams from Pinyin2Hanzi import dag dagparams = DefaultDagParams() print( dag(dagparams, [u'ti', u'chu', u'le', u'jie', u'jve', u'fang', u'an'], path_num=1) ) print( dag(dag...
541
22.565217
91
py
Pinyin2Hanzi
Pinyin2Hanzi-master/example/dag_pinyin2hanzi.py
# coding: utf-8 from __future__ import (print_function, unicode_literals) import sys sys.path.append('..') from Pinyin2Hanzi import DefaultDagParams from Pinyin2Hanzi import dag dagparams = DefaultDagParams() result = dag(dagparams, ['wo']) for item in result: print(item.score, '/'.join(item.path)) print(20*'...
1,477
22.83871
91
py
Few-shot-WSI
Few-shot-WSI-master/setup.py
#!/usr/bin/env python import os import subprocess import time from setuptools import find_packages, setup def readme(): with open('README.md', encoding='utf-8') as f: content = f.read() return content MAJOR = 0 MINOR = 3 PATCH = 0 SUFFIX = '' if PATCH != '': SHORT_VERSION = '{}.{}.{}{}'.format(M...
6,047
30.5
125
py
Few-shot-WSI
Few-shot-WSI-master/tools/test.py
import argparse import importlib import os import os.path as osp import time import mmcv import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, init_dist, load_checkpoint from openselfsup.datasets import build_dataloader, build_dataset from openselfsup....
3,944
31.073171
83
py
Few-shot-WSI
Few-shot-WSI-master/tools/publish_model.py
import argparse import subprocess def parse_args(): parser = argparse.ArgumentParser( description='Process a checkpoint to be published') parser.add_argument('in_file', help='input checkpoint filename') args = parser.parse_args() return args def process_checkpoint(in_file): tmp_file = in...
898
25.441176
68
py
Few-shot-WSI
Few-shot-WSI-master/tools/extract.py
import argparse import importlib import numpy as np import os import os.path as osp import time import mmcv import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, init_dist, load_checkpoint from openselfsup.utils import dist_forward_collect, nondist_for...
6,703
35.63388
77
py
Few-shot-WSI
Few-shot-WSI-master/tools/upgrade_models.py
import torch import argparse def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('checkpoint', help='checkpoint file') parser.add_argument( '--save-path', type=str, required=True, help='destination file name') args = parser.parse_args() return args def main(): ar...
712
24.464286
77
py
Few-shot-WSI
Few-shot-WSI-master/tools/extract_backbone_weights.py
import torch import argparse def parse_args(): parser = argparse.ArgumentParser( description='This script extracts backbone weights from a checkpoint') parser.add_argument('checkpoint', help='checkpoint file') parser.add_argument( 'output', type=str, help='destination file name') args ...
952
28.78125
78
py
Few-shot-WSI
Few-shot-WSI-master/tools/train.py
from __future__ import division import argparse import importlib import os import os.path as osp import time import mmcv import torch from mmcv import Config from mmcv.runner import init_dist from openselfsup import __version__ from openselfsup.apis import set_random_seed, train_model from openselfsup.datasets import...
5,150
33.112583
86
py
Few-shot-WSI
Few-shot-WSI-master/tools/count_parameters.py
import argparse from mmcv import Config from openselfsup.models import build_model def parse_args(): parser = argparse.ArgumentParser(description='Train a model') parser.add_argument('config', help='train config file path') args = parser.parse_args() return args def main(): args = parse_args() ...
1,201
29.820513
83
py
Few-shot-WSI
Few-shot-WSI-master/tools/prepare_data/convert_subset.py
""" SimCLR provides list files for semi-supervised benchmarks: https://github.com/google-research/simclr/tree/master/imagenet_subsets/ This script convert the list files into the required format in OpenSelfSup. """ import argparse parser = argparse.ArgumentParser( description='Convert ImageNet subset lists provide...
1,162
31.305556
75
py
Few-shot-WSI
Few-shot-WSI-master/tools/prepare_data/create_voc_data_files.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ################################################################################ """ This script can be used to extract th...
7,741
38.907216
80
py
Few-shot-WSI
Few-shot-WSI-master/tools/prepare_data/create_voc_low_shot_challenge_samples.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # ################################################################################ """ This script is used to create the low...
4,741
34.924242
80
py
Few-shot-WSI
Few-shot-WSI-master/wsi_workdir/dict_construction.py
import numpy as np from openselfsup.third_party import clustering from scipy.spatial.distance import cdist import os import warnings import time import pickle as pkl from sklearn.neighbors import KNeighborsClassifier from scipy.special import softmax import argparse Kmeans = clustering.__dict__['Kmeans'] pth = 'wsi_w...
3,061
39.289474
111
py
Few-shot-WSI
Few-shot-WSI-master/wsi_workdir/distributed_meta_test.py
import argparse import datetime import scipy import numpy as np from scipy.stats import t from sklearn.linear_model import RidgeClassifier, LogisticRegression from sklearn.neighbors import NearestCentroid from sklearn.metrics import f1_score from scipy.spatial.distance import cdist from tqdm.contrib.concurrent import p...
6,809
43.220779
144
py
Few-shot-WSI
Few-shot-WSI-master/wsi_workdir/extract.py
import argparse import importlib import numpy as np import os import os.path as osp import time from tqdm import trange,tqdm import threading import mmcv import torch from mmcv.parallel import MMDataParallel, MMDistributedDataParallel from mmcv.runner import get_dist_info, init_dist, load_checkpoint from openselfsup...
3,789
29.564516
109
py
Few-shot-WSI
Few-shot-WSI-master/wsi_workdir/tools/generate_aug_NCT78_task.py
import numpy as np import argparse import os import warnings import threading from tqdm import tqdm warnings.filterwarnings("ignore") def aug_NCT78_task(out_dir, task_ids, num_shots, options): task_name = f'9-way-{num_shots}-shot' out_dir = f'{out_dir}/NCT_78_aug' for _ in tqdm(range(len(task_ids))): ...
5,792
40.378571
144
py
Few-shot-WSI
Few-shot-WSI-master/wsi_workdir/tools/generate_task.py
import numpy as np import argparse import os import warnings import threading from tqdm import tqdm warnings.filterwarnings("ignore") def generate_near_domain_task(out_dir, task_ids, num_shots, options): out_dir = f'{out_dir}/near' nv = options['novel_class'] if options['initialization'] or options['over...
13,175
46.225806
144
py