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
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/evaluation/coco/__init__.py
from .coco_eval import do_coco_evaluation def coco_evaluation( dataset, predictions, output_folder, box_only, iou_types, expected_results, expected_results_sigma_tol, ): return do_coco_evaluation( dataset=dataset, predictions=predictions, box_only=box_only, ...
494
21.5
62
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/evaluation/coco/coco_eval.py
import logging import tempfile import os import torch from collections import OrderedDict from tqdm import tqdm # from lib.scene_parser.rcnn.modeling.roi_heads.mask_head.inference import Masker from lib.scene_parser.rcnn.structures.bounding_box import BoxList from lib.scene_parser.rcnn.structures.boxlist_ops import bo...
14,329
34.914787
89
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/samplers/grouped_batch_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import itertools import torch from torch.utils.data.sampler import BatchSampler from torch.utils.data.sampler import Sampler class GroupedBatchSampler(BatchSampler): """ Wraps another sampler to yield a mini-batch of indices. It enfo...
4,845
40.775862
88
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/samplers/iteration_based_batch_sampler.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from torch.utils.data.sampler import BatchSampler class IterationBasedBatchSampler(BatchSampler): """ Wraps a BatchSampler, resampling from it until a specified number of iterations have been sampled """ def __init__(self, ba...
1,164
35.40625
71
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/samplers/distributed.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. # Code is copy-pasted exactly as in torch.utils.data.distributed. # FIXME remove this once c10d fixes the bug it has import math import torch import torch.distributed as dist from torch.utils.data.sampler import Sampler class DistributedSampler(S...
2,569
37.358209
86
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/samplers/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .distributed import DistributedSampler from .grouped_batch_sampler import GroupedBatchSampler from .iteration_based_batch_sampler import IterationBasedBatchSampler __all__ = ["DistributedSampler", "GroupedBatchSampler", "IterationBasedBatchSa...
328
46
85
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/transforms/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .transforms import Compose from .transforms import Resize from .transforms import RandomHorizontalFlip from .transforms import ToTensor from .transforms import Normalize from .build import build_transforms
284
30.666667
71
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/transforms/build.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from . import transforms as T def build_transforms(cfg, is_train=True): if is_train: min_size = cfg.INPUT.MIN_SIZE_TRAIN max_size = cfg.INPUT.MAX_SIZE_TRAIN flip_horizontal_prob = 0.5 # cfg.INPUT.FLIP_PROB_TRAIN ...
1,533
32.347826
121
py
graph-rcnn.pytorch
graph-rcnn.pytorch-master/lib/data/transforms/transforms.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import random import torch import torchvision from torchvision.transforms import functional as F class Compose(object): def __init__(self, transforms): self.transforms = transforms def __call__(self, image, target): for ...
3,477
27.508197
83
py
DMCrypt
DMCrypt-main/main.py
import torch import torch.nn as nn import pandas as pd import numpy as np from torch.utils.data import Dataset, DataLoader from torch.autograd import Variable from sklearn.preprocessing import MinMaxScaler, StandardScaler #import seaborn as sns import matplotlib.pyplot as plt import pickle5 as pickle import sys import...
641
28.181818
97
py
DMCrypt
DMCrypt-main/utils/utils.py
import numpy as np import pickle5 as pickle def create_sequences(x, window): newDataframe =[] for rowIndex in range(x.shape[0]-window): inputSequence = [] newDataframe.append(x[rowIndex: rowIndex+window]) #newDataframe.append(inputSequence) return np.array(newDataframe) def getPr...
1,086
32.96875
160
py
DMCrypt
DMCrypt-main/model/AdaBoost-LSTM.py
import torch import torch.nn as nn import pickle5 as pickle import pandas as pd import numpy as np from torch.utils.data import Dataset, DataLoader from torch.autograd import Variable from sklearn.ensemble import AdaBoostRegressor, GradientBoostingRegressor from sklearn.metrics import mean_absolute_error, mean_squared...
7,495
33.703704
163
py
DMCrypt
DMCrypt-main/model/LSTM.py
import torch import torch.nn as nn import pickle import pandas as pd import numpy as np from torch.utils.data import Dataset, DataLoader from torch.autograd import Variable from sklearn.preprocessing import MinMaxScaler, StandardScaler #import seaborn as sns import matplotlib.pyplot as plt import pickle5 as pickle de...
1,806
38.282609
97
py
unarXive
unarXive-master/src/extend_matched.py
""" This script takes enhanced chunks of arXiv data and enriches the publications therein with discipline information and further their included bibliography items with discipline information and arXiv IDs from an OpenAlex data dump, provided the item matching against the OpenAlex data is successful """ from arxiv_tax...
8,864
39.113122
120
py
unarXive
unarXive-master/src/match_references_openalex.py
""" This script extends parsed arXiv chunks with a set of identifiers by matching the included publications against OpenAlex data in local DB and against an arXiv metadata table """ import psycopg2 import json import os import glob import re import unidecode import unicodedata import sqlite3 import requests import sys...
34,022
45.039242
203
py
unarXive
unarXive-master/src/prepare.py
""" Normalize and parse. """ import os import shutil import sys import tarfile import tempfile import time from normalize_arxiv_dump import normalize from parse_latex_tralics import parse def prepare(in_dir, out_dir, meta_db, tar_fn_patt, write_logs=False): if not os.path.isdir(in_dir): print('input dire...
4,977
34.81295
79
py
unarXive
unarXive-master/src/normalize_arxiv_dump.py
""" Normalize a arXiv dump - copy PDF files as is - unzip gzipped single files - copy if it's a LaTeX file - extract gzipped tar archives - try to flatten contents to a single LaTeX file - ignores non LaTeX contents (HTML, PS, TeX, ...) """ import chardet import gzip import magic i...
9,566
36.665354
87
py
unarXive
unarXive-master/src/parse_latex_tralics.py
""" Convert LaTeX files to S2ORC like JSONL output """ import json import os import re import sqlite3 import subprocess import sys import tempfile import uuid # import IPython from collections import OrderedDict, defaultdict from hashlib import sha1 from lxml import etree from tqdm import tqdm PDF_EXT_PATT = re.compi...
23,318
35.209627
83
py
unarXive
unarXive-master/src/utility_scripts/count_licenses.py
import json import os import sys from collections import defaultdict def license_counts_from_json(fp): license_counts = defaultdict(int) with open(fp) as f: for line in f: ppr = json.loads(line.strip()) license = ppr.get('metadata', {}).get('license') license_counts...
1,091
27
71
py
unarXive
unarXive-master/src/utility_scripts/arxiv_taxonomy.py
"""Category and archive definitions. Copy of https://github.com/arXiv/arxiv-base/blob/ develop/arxiv/taxonomy/definitions.py retrieved 2023/01/25. """ from datetime import date GROUPS = { 'grp_physics': { 'name': 'Physics', 'start_year': 1991, 'default_archive': 'hep-t...
90,885
40.576395
98
py
unarXive
unarXive-master/src/utility_scripts/generate_openalex_db.py
""" Reads data from OpenAlex dump files (works type) and it into a local DB imported are title, authors, citation counts and IDs """ import psycopg2 from psycopg2.extras import Json, DictCursor import json import os import glob import gzip import re import unidecode import unicodedata def normalize_title(title_...
9,243
39.017316
209
py
unarXive
unarXive-master/src/utility_scripts/generate_openalex_db_using_locations.py
""" this script reads data from OpenAlex dump files (works type) and imports it into a local DB extracted are title, authors, citation counts, discipline info, open access URLs and IDs this version is adapted to fit the new OpenAlex structure including "locations" entities """ import psycopg2 from psycopg2.ext...
9,581
39.601695
209
py
unarXive
unarXive-master/src/utility_scripts/ml_tasks_prep_data.py
""" Generate train/test data for two ML tasks - content based citation recommendation - IMRaD classification based on the full unarXive data set. Data generation in done for both tasks together because both take single paragraphs from papers an input. The script nicely prepares paragraphs (repl...
14,451
36.733681
79
py
unarXive
unarXive-master/src/utility_scripts/generate_metadata_db.py
""" From an arXiv metadata snapshot as provided by https://www.kaggle.com/Cornell-University/arxiv generate an SQLite database with indices for performant access. """ import json import os import re import sqlite3 import sys from tqdm import tqdm def gen_meta_db(in_fp): # input prep in_path, in_f...
1,808
26.409091
78
py
unarXive
unarXive-master/src/utility_scripts/calc_stats.py
""" Calculate dataset stats across - time (years / months) - disciplines (see https://arxiv.org/category_taxonomy) For - paragraphs - paragraph types - references - citation markers - figures - tables - mathematical notation """ import json import os import sys import numpy as ...
21,643
30.053085
79
py
unarXive
unarXive-master/src/utility_scripts/filter_permissively_livensed.py
""" Filter every JSONL to only contain permissively licensed papers. Only use papers licensed - Public Domain - CC-Zero - CC-BY - CC-BY-SA such that the final data set can be shared as CC-BY-SA. """ import json import os import sys from collections import defaultdict def is_permissive(licens...
3,375
30.259259
77
py
unarXive
unarXive-master/src/utility_scripts/ml_tasks_split_data.py
""" Split data pepared by script ml_task_prep_data.py into train, dev, and test. Stratified sampling is used wrt. - target clabel (class) - (citing) paper discipline - paper publication year """ import json import math import os import random import sys import uuid from collections import defaultd...
11,615
35.759494
77
py
paper-log-bilinear-loss
paper-log-bilinear-loss-master/test.py
""" Put it all together with a simple MNIST exmaple """ from tensorflow.examples.tutorials.mnist import input_data from keras.optimizers import Adam from sklearn.metrics import confusion_matrix from models import mnist_model from loss import bilinear_loss from util import * DATA_DIR = "" LRATE = 5e-4 ...
2,044
34.877193
119
py
paper-log-bilinear-loss
paper-log-bilinear-loss-master/loss.py
import numpy as np import tensorflow as tf from keras import backend as K def loss_function_generator(conf_mat, log=False, alpha=.5): """ Generate Bilinear/Log-Bilinear loss functions combined with the rgular cross-entorpy loss (1 - alpha)*cross_entropy_loss + alpha*bilinar/log-bilinar :param conf_m...
1,997
38.176471
154
py
paper-log-bilinear-loss
paper-log-bilinear-loss-master/util.py
import numpy as np def confusion_matrix_normalizer(cm, strip_diagonal=True, normalize_rows=True, normalize_matrix=False): cm = cm.astype(np.float32) # Get rid of the diagonal. This allows to consider only the error-part of the conf-mat. if strip_diagonal: cm -= np.diag(cm) * np.eye(cm.shape[0]) ...
1,284
26.934783
111
py
paper-log-bilinear-loss
paper-log-bilinear-loss-master/models.py
from keras.layers import Dense, Dropout, Activation, Flatten, Convolution2D, MaxPooling2D from keras.models import Sequential def mnist_model(): model = Sequential() model.add(Convolution2D(20, 5, 5, border_mode='same', activation='relu', input_shape=(28, 28, 1))) model.add(MaxPooling2D(pool_size=(2, 2))...
2,914
41.246377
102
py
cb_bakeoff
cb_bakeoff-master/oml_to_vw.py
import argparse from config import OML_API_KEY import gzip import openml import os import scipy.sparse as sp VW_DS_DIR = 'vwdatasets/' def save_vw_dataset(X, y, did, ds_dir): n_classes = y.max() + 1 fname = 'ds_{}_{}.vw.gz'.format(did, n_classes) with gzip.open(os.path.join(ds_dir, fname), 'w') as f: ...
4,728
74.063492
2,752
py
cb_bakeoff
cb_bakeoff-master/eval_common.py
import gzip import pickle import re import sys import numpy as np import pandas as pd def load_raw(loss_file, adf=True, cb_type=None, min_actions=None, min_size=None, shuffle=False): if adf: rgx = re.compile(r'^ds:(.+)\|na:(\d+)\|cb_type:(.*)\|(.*)\|(.*) (.*)$', flags=re.M) if loss_file.endswith('...
2,103
36.571429
96
py
cb_bakeoff
cb_bakeoff-master/paper_scatterplots.py
import matplotlib matplotlib.use('Agg') import argparse from eval_loss import load_names from rank_algos import significance, significance_cs01, preprocess_df_granular, preprocess_df, base_name, set_base_name import matplotlib.pyplot as plt import numpy as np import os plt.style.use('ggplot') FIGDIR = '/scratch/clear/...
13,716
44.876254
119
py
cb_bakeoff
cb_bakeoff-master/full_to_ldf.py
""" Helper script for mslr/yahoo learning-to-rank datasets. To be used as follows (for 10 different shuffles): ### MSLR cat train.txt vali.txt test.txt | python make_full.py > train_full.txt for i in {1..10}; do shuf vw_full.txt > vw_full$i.txt; done for i in {1..10}; do cat vw_full$i.txt | python full...
1,006
37.730769
106
py
cb_bakeoff
cb_bakeoff-master/make_full.py
""" Helper script for mslr/yahoo learning-to-rank datasets. To be used as follows (for 10 different shuffles): ### MSLR cat train.txt vali.txt test.txt | python make_full.py > train_full.txt for i in {1..10}; do shuf vw_full.txt > vw_full$i.txt; done for i in {1..10}; do cat vw_full$i.txt | python full...
1,716
32.666667
106
py
cb_bakeoff
cb_bakeoff-master/multilabel_to_vw.py
""" Script for converting multi-label datasets to VW format. The multi-label datasets in the original libsvm format can be found here: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html note: for simulating bandit feedback, use the options `--cbify <num_actions> --cbify_cs` in VW """ import a...
1,210
36.84375
94
py
cb_bakeoff
cb_bakeoff-master/rank_algos.py
import argparse import numpy as np import os import pandas as pd import pickle import re import sys from collections import defaultdict from eval_loss import load_names from scipy.special import erf, erfinv _base_name = 'disagree' def base_name(): global _base_name return _base_name def set_base_name(name): ...
10,164
36.509225
134
py
cb_bakeoff
cb_bakeoff-master/paper_tables.py
import argparse from eval_loss import load_names from rank_algos import significance, significance_cs01, preprocess_df_granular, preprocess_df, base_name, set_base_name import numpy as np MTR_LABEL = 'iwr' def wins_losses(df, xname, yname, args=None): rawx = df.loc[df.algo == xname].groupby('ds').rawloss.mean() ...
26,361
44.063248
139
py
cb_bakeoff
cb_bakeoff-master/eval_loss.py
import eval_common import argparse import os import pickle import random import re import sys import numpy as np import pandas as pd USE_ADF = True USE_CS = False DIR_PATTERN_CS = '/scratch/clear/abietti/cb_eval/res_cs/cbresults_{}/' DIR_PATTERN = '/scratch/clear/abietti/cb_eval/res/cbresults_{}/' # DIR_PATTERN = '...
9,825
38.943089
136
py
cb_bakeoff
cb_bakeoff-master/run_vw_job.py
import argparse import os import re import subprocess import sys import time USE_ADF = True USE_CS = False RANDOM_TIE = True VW = '/scratch/clear/abietti/.local/bin/vw' if USE_CS: VW_DS_DIR = '/scratch/clear/abietti/cb_eval/vwshuffled_cs/' DIR_PATTERN = '/scratch/clear/abietti/cb_eval/res_cs/cbresults_{}/' el...
6,984
34.277778
106
py
cb_bakeoff
cb_bakeoff-master/best_hyperparams.py
import argparse import numpy as np import os import pandas as pd import pickle import re import sys from collections import defaultdict from eval_loss import load_names from rank_algos import significance, significance_cs01, preprocess_df_granular, preprocess_df, base_name, set_base_name from scipy.special import erf, ...
5,328
33.380645
119
py
DCAP
DCAP-main/layer.py
import numpy as np import torch import torch.nn.functional as F from torchfm.utils import get_activation_fn from torchfm.attention_layer import MultiheadAttentionInnerProduct class FeaturesLinear(torch.nn.Module): def __init__(self, field_dims, output_dim=1): super().__init__() self.fc = torch.nn....
12,567
36.404762
141
py
DCAP
DCAP-main/utils.py
import torch.nn.functional as F import torch def get_activation_fn(activation: str): """ Returns the activation function corresponding to `activation` """ if activation == "relu": return F.relu # elif activation == "gelu": # return gelu # elif activation == "gelu_fast": # depre...
736
31.043478
81
py
DCAP
DCAP-main/attention_layer.py
import numpy as np import torch import torch.nn.functional as F from torchfm.utils import get_activation_fn class MultiheadAttentionInnerProduct(torch.nn.Module): def __init__(self, num_fields, embed_dim, num_heads, dropout): super().__init__() self.num_fields = num_fields self.mask = (to...
14,427
40.45977
171
py
DCAP
DCAP-main/dataset/rapid.py
import math import shutil import struct from collections import defaultdict from functools import lru_cache from pathlib import Path import lmdb import numpy as np import torch.utils.data from tqdm import tqdm class RapidAdvanceDataset(torch.utils.data.Dataset): """ MovieLens 1M Dataset Data preparation...
1,866
27.287879
88
py
DCAP
DCAP-main/dataset/avazu.py
import shutil import struct from collections import defaultdict from pathlib import Path import lmdb import numpy as np import torch.utils.data from tqdm import tqdm class AvazuDataset(torch.utils.data.Dataset): """ Avazu Click-Through Rate Prediction Dataset Dataset preparation Remove the infre...
4,268
41.267327
119
py
DCAP
DCAP-main/dataset/frappe.py
import numpy as np import pandas as pd import torch.utils.data class FrappeDataset(torch.utils.data.Dataset): """ Frappe Dataset Data preparation treat apps with a rating less than 3 as negative samples :param dataset_path: frappe dataset path Reference: https://? """ d...
1,833
33.603774
144
py
DCAP
DCAP-main/dataset/criteo.py
import math import shutil import struct from collections import defaultdict from functools import lru_cache from pathlib import Path import lmdb import numpy as np import torch.utils.data from tqdm import tqdm class CriteoDataset(torch.utils.data.Dataset): """ Criteo Display Advertising Challenge Dataset ...
5,072
41.630252
120
py
DCAP
DCAP-main/dataset/movielens.py
import numpy as np import pandas as pd import torch.utils.data class MovieLens20MDataset(torch.utils.data.Dataset): """ MovieLens 20M Dataset Data preparation treat samples with a rating less than 3 as negative samples :param dataset_path: MovieLens dataset path Reference: https...
2,695
32.7
103
py
DCAP
DCAP-main/model/dcn.py
import torch from torchfm.layer import FeaturesEmbedding, CrossNetwork, MultiLayerPerceptron class DeepCrossNetworkModel(torch.nn.Module): """ A pytorch implementation of Deep & Cross Network. Reference: R Wang, et al. Deep & Cross Network for Ad Click Predictions, 2017. """ def __init_...
1,159
35.25
101
py
DCAP
DCAP-main/model/fnn.py
import torch from torchfm.layer import FeaturesEmbedding, MultiLayerPerceptron class FactorizationSupportedNeuralNetworkModel(torch.nn.Module): """ A pytorch implementation of Neural Factorization Machine. Reference: W Zhang, et al. Deep Learning over Multi-field Categorical Data - A Case Study ...
924
33.259259
121
py
DCAP
DCAP-main/model/ffm.py
import torch from torchfm.layer import FeaturesLinear, FieldAwareFactorizationMachine class FieldAwareFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Field-aware Factorization Machine. Reference: Y Juan, et al. Field-aware Factorization Machines for CTR Prediction, 20...
809
30.153846
83
py
DCAP
DCAP-main/model/wd.py
import torch from torchfm.layer import FeaturesLinear, MultiLayerPerceptron, FeaturesEmbedding class WideAndDeepModel(torch.nn.Module): """ A pytorch implementation of wide and deep learning. Reference: HT Cheng, et al. Wide & Deep Learning for Recommender Systems, 2016. """ def __init_...
931
32.285714
81
py
DCAP
DCAP-main/model/ncf.py
import torch from torchfm.layer import FeaturesEmbedding, MultiLayerPerceptron class NeuralCollaborativeFiltering(torch.nn.Module): """ A pytorch implementation of Neural Collaborative Filtering. Reference: X He, et al. Neural Collaborative Filtering, 2017. """ def __init__(self, field_d...
1,248
35.735294
101
py
DCAP
DCAP-main/model/dcan.py
import torch from torchfm.layer import ( FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron ) from torchfm.attention_layer import CrossAttentionNetwork class DeepCrossAttentionalNetworkModel(torch.nn.Module): """ A pytorch implementation of Multihead Attention Factorization Machine Model. ...
2,471
40.2
120
py
DCAP
DCAP-main/model/afn.py
import math import torch import torch.nn.functional as F from torchfm.layer import FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron class LNN(torch.nn.Module): """ A pytorch implementation of LNN layer Input shape - A 3D tensor with shape: ``(batch_size,field_size,embedding_size)``. Out...
3,088
35.341176
107
py
DCAP
DCAP-main/model/fnfm.py
import torch from torchfm.layer import FieldAwareFactorizationMachine, MultiLayerPerceptron, FeaturesLinear class FieldAwareNeuralFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Field-aware Neural Factorization Machine. Reference: L Zhang, et al. Field-aware Neural Fa...
1,251
38.125
105
py
DCAP
DCAP-main/model/dcap.py
import torch from torchfm.layer import FeaturesEmbedding, FeaturesLinear, CrossAttentionalProductNetwork, MultiLayerPerceptron class DeepCrossAttentionalProductNetwork(torch.nn.Module): """ A pytorch implementation of inner/outer Product Neural Network. Reference: Y Qu, et al. Product-based Neura...
2,887
46.344262
113
py
DCAP
DCAP-main/model/afi.py
import torch import torch.nn.functional as F from torchfm.layer import FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron class AutomaticFeatureInteractionModel(torch.nn.Module): """ A pytorch implementation of AutoInt. Reference: W Song, et al. AutoInt: Automatic Feature Interaction Learni...
2,157
43.040816
125
py
DCAP
DCAP-main/model/nfm.py
import torch from torchfm.layer import FactorizationMachine, FeaturesEmbedding, MultiLayerPerceptron, FeaturesLinear class NeuralFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Neural Factorization Machine. Reference: X He and TS Chua, Neural Factorization Machines fo...
1,096
33.28125
103
py
DCAP
DCAP-main/model/hofm.py
import torch from torchfm.layer import FeaturesLinear, FactorizationMachine, AnovaKernel, FeaturesEmbedding class HighOrderFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Higher-Order Factorization Machines. Reference: M Blondel, et al. Higher-Order Factorization Mach...
1,473
34.095238
94
py
DCAP
DCAP-main/model/pnn.py
import torch from torchfm.layer import FeaturesEmbedding, FeaturesLinear, InnerProductNetwork, \ OuterProductNetwork, MultiLayerPerceptron class ProductNeuralNetworkModel(torch.nn.Module): """ A pytorch implementation of inner/outer Product Neural Network. Reference: Y Qu, et al. Product-base...
1,421
37.432432
118
py
DCAP
DCAP-main/model/mhafm.py
import torch from torchfm.layer import FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron from torchfm.attention_layer import CrossAttentionalProductNetwork class MultiheadAttentionalFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Multihead Attention Factorization Machine Mod...
2,488
45.092593
141
py
DCAP
DCAP-main/model/dfm.py
import torch from torchfm.layer import FactorizationMachine, FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron class DeepFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of DeepFM. Reference: H Guo, et al. DeepFM: A Factorization-Machine based Neural Network for CTR...
1,049
35.206897
103
py
DCAP
DCAP-main/model/lr.py
import torch from torchfm.layer import FeaturesLinear class LogisticRegressionModel(torch.nn.Module): """ A pytorch implementation of Logistic Regression. """ def __init__(self, field_dims): super().__init__() self.linear = FeaturesLinear(field_dims) def forward(self, x): ...
461
22.1
66
py
DCAP
DCAP-main/model/xdfm.py
import torch from torchfm.layer import CompressedInteractionNetwork, FeaturesEmbedding, FeaturesLinear, MultiLayerPerceptron class ExtremeDeepFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of xDeepFM. Reference: J Lian, et al. xDeepFM: Combining Explicit and Implicit Fe...
1,157
38.931034
115
py
DCAP
DCAP-main/model/fm.py
import torch from torchfm.layer import FactorizationMachine, FeaturesEmbedding, FeaturesLinear class FactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Factorization Machine. Reference: S Rendle, Factorization Machines, 2010. """ def __init__(self, field_dims, e...
746
27.730769
81
py
DCAP
DCAP-main/model/afm.py
import torch from torchfm.layer import FeaturesEmbedding, FeaturesLinear, AttentionalFactorizationMachine class AttentionalFactorizationMachineModel(torch.nn.Module): """ A pytorch implementation of Attentional Factorization Machine. Reference: J Xiao, et al. Attentional Factorization Machines: ...
956
34.444444
132
py
NimPlant
NimPlant-main/NimPlant.py
#!/usr/bin/python3 # ----- # # NimPlant - A light-weight stage 1 implant and C2 written in Nim and Python # By Cas van Cooten (@chvancooten) # # This is a wrapper script to configure and generate NimPlant and its C2 server # # ----- import os import random import time import toml from pathlib import Path from c...
9,645
33.084806
124
py
NimPlant
NimPlant-main/client/dist/srdi/ShellcodeRDI.py
import sys if sys.version_info < (3,0): print("[!] Sorry, requires Python 3.x") sys.exit(1) import struct from struct import pack MACHINE_IA64=512 MACHINE_AMD64=34404 def is64BitDLL(bytes): header_offset = struct.unpack("<L", bytes[60:64])[0] machine = struct.unpack("<H", bytes[header_offset+4:h...
29,801
135.706422
12,132
py
NimPlant
NimPlant-main/ui/build-ui.py
#!/usr/bin/python3 # ----- # # NimPlant - A light-weight stage 1 implant and C2 written in Nim and Python # By Cas van Cooten (@chvancooten) # # This is a helper script to build the Next.JS frontend # and move it to the right directory for use with Nimplant. # End-users should not need to use this script, un...
1,091
21.285714
78
py
NimPlant
NimPlant-main/server/server.py
#!/usr/bin/python3 # ----- # # NimPlant Server - The "C2-ish"™ handler for the NimPlant payload # By Cas van Cooten (@chvancooten) # # ----- import threading import time from .api.server import api_server, server_ip, server_port from .util.db import initDb, dbInitNewServer, dbPreviousServerSameConfig from .util....
2,093
30.253731
133
py
NimPlant
NimPlant-main/server/__init__.py
0
0
0
py
NimPlant
NimPlant-main/server/api/server.py
from ..util.commands import getCommands, handleCommand from ..util.config import config from ..util.crypto import randString from ..util.func import exitServer from ..util.nimplant import np_server from flask_cors import CORS from gevent.pywsgi import WSGIServer from server.util.db import * from threading import Threa...
7,245
35.969388
88
py
NimPlant
NimPlant-main/server/api/__init__.py
0
0
0
py
NimPlant
NimPlant-main/server/util/db.py
import sqlite3 from .config import config from .func import timestamp, nimplantPrint con = sqlite3.connect( "server/nimplant.db", check_same_thread=False, detect_types=sqlite3.PARSE_DECLTYPES ) # Use the Row type to allow easy conversions to dicts con.row_factory = sqlite3.Row # Handle bool as 1 (True) and 0 (Fa...
14,703
33.516432
124
py
NimPlant
NimPlant-main/server/util/notify.py
import os import requests import urllib.parse # This is a placeholder class for easy extensibility, more than anything # You can easily add your own notification method below, and call it in the 'notify_user' function # It will then be called when a new implant checks in, passing the NimPlant object (see nimplant.py) ...
1,576
31.854167
100
py
NimPlant
NimPlant-main/server/util/listener.py
from .config import config from .crypto import * from .func import * from .nimplant import * from .notify import notify_user from gevent.pywsgi import WSGIServer from zlib import decompress, compress import base64 import flask import gzip import hashlib import io import json # Parse configuration from 'config.toml' tr...
14,535
40.89049
154
py
NimPlant
NimPlant-main/server/util/commands.py
from .func import log, nimplantPrint from .nimplant import np_server from yaml.loader import FullLoader import shlex import yaml def getCommands(): with open("server/util/commands.yaml", "r") as f: return sorted(yaml.load(f, Loader=FullLoader), key=lambda c: c["command"]) def getCommandList(): retur...
4,762
28.583851
116
py
NimPlant
NimPlant-main/server/util/config.py
import os, sys, toml # Parse server configuration configPath = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), 'config.toml')) config = toml.load(configPath)
169
33
87
py
NimPlant
NimPlant-main/server/util/nimplant.py
import datetime, itertools, random, string from re import T from secrets import choice from .config import config from .func import * from .db import * # Parse configuration from 'config.toml' try: initialSleepTime = config["nimplant"]["sleepTime"] initialSleepJitter = config["nimplant"]["sleepTime"] killD...
12,863
31.484848
106
py
NimPlant
NimPlant-main/server/util/__init__.py
0
0
0
py
NimPlant
NimPlant-main/server/util/func.py
from datetime import datetime from struct import pack, calcsize from time import sleep from zlib import compress import base64 import os, hashlib, json, sys # Clear screen def cls(): if os.name == "nt": os.system("cls") else: os.system("clear") # Timestamp function timestampFormat = "%d/%m/%Y...
16,749
28.334501
145
py
NimPlant
NimPlant-main/server/util/crypto.py
import base64, string, random from Crypto.Cipher import AES from Crypto.Util import Counter # XOR function to transmit key securely. Matches nimplant XOR function in 'client/util/crypto.nim' def xorString(value, key): k = key result = [] for c in value: character = ord(c) for f in [0, 8, 16...
1,825
34.115385
98
py
NimPlant
NimPlant-main/server/util/input.py
import os # Command history and command / path completion on Linux if os.name == "posix": import readline from .commands import getCommandList commands = getCommandList() def list_folder(path): if path.startswith(os.path.sep): # absolute path basedir = os.path.dirname(...
2,423
30.076923
130
py
CropRowDetection
CropRowDetection-main/unet-rgbd/dataRGB.py
# -*- coding:utf-8 -*- from keras.preprocessing.image import img_to_array, load_img import numpy as np import glob class dataProcess(object): def __init__(self, out_rows, out_cols, data_path="./data/train/image", label_path="./data/train/label", test_path="./data/test/image", testlabel_path="./d...
5,060
37.340909
122
py
CropRowDetection
CropRowDetection-main/unet-rgbd/unetRGB.py
# -*- coding:utf-8 -*- import os import tensorflow as tf os.environ["CUDA_VISIBLE_DEVICES"] = "0" #print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) from tensorflow.keras.models import * from tensorflow.keras.layers import * from tensorflow.keras.optimizers import * from tensorflow.keras.c...
15,916
42.135501
201
py
CropRowDetection
CropRowDetection-main/unet-rgbd/mask2str.py
# -*- coding:utf-8 -*- # E.g. '1 3' implies starting at pixel 1 and running a total of 3 pixels (1,2,3). # The pixels are numbered from top to bottom, then left to right: 1 is pixel (1,1), 2 is pixel (2,1), etc. import cv2 import numpy as np # test = np.array([[0,1,0],[1,0,1]]) # print(np.where(test.flatten(order='F'...
637
28
106
py
CropRowDetection
CropRowDetection-main/unet-rgbd/test2mask2pic.py
# -*- coding:utf-8 -*- from unetwsess import * from data import * myunet = myUnet() model = myunet.get_unet() model.load_weights('unet.hdf5') # test2mask imgs_train, imgs_mask_train, imgs_test, imgs_testlabels = myunet.load_data() imgs_mask_test = model.predict(imgs_test, batch_size=1, verbose=1) np.save('./results/...
447
21.4
76
py
CropRowDetection
CropRowDetection-main/unet-rgbd/unetRGBD.py
# -*- coding:utf-8 -*- import os import tensorflow as tf os.environ["CUDA_VISIBLE_DEVICES"] = "0" #print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU'))) from tensorflow.keras.models import * from tensorflow.keras.layers import * from tensorflow.keras.optimizers import * from tensorflow.keras.c...
15,916
42.135501
202
py
CropRowDetection
CropRowDetection-main/unet-rgbd/dataRGBD.py
# -*- coding:utf-8 -*- from keras.preprocessing.image import img_to_array, load_img import numpy as np import glob class dataProcess(object): def __init__(self, out_rows, out_cols, data_path="./data/train/image", depth_path="./data/train/depth", label_path="./data/train/label", test_path="./data...
5,828
39.479167
158
py
Traffic-Benchmark
Traffic-Benchmark-master/train_benchmark.py
import os import random import numpy as np import torch # import setproctitle import argparse parser = argparse.ArgumentParser() parser.add_argument('--model',type=str,default='DGCRN',help='model') parser.add_argument('--data',type=str,default='METR-LA',help='dataset') args = parser.parse_args() model = args.model da...
6,887
46.833333
298
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/dcrnn_train_pytorch.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import yaml from lib.utils import load_graph_data from model.pytorch.dcrnn_supervisor import DCRNNSupervisor import setproctitle setproctitle.setproctitle("stmetanet@lifuxian") def main(args):...
1,459
38.459459
129
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/run_demo_pytorch.py
import argparse import numpy as np import os import sys import yaml from lib.utils import load_graph_data from model.pytorch.dcrnn_supervisor import DCRNNSupervisor def run_dcrnn(args): with open(args.config_filename) as f: supervisor_config = yaml.load(f) graph_pkl_filename = supervisor_config[...
1,264
36.205882
108
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/dcrnn_train.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import tensorflow as tf import yaml from lib.utils import load_graph_data from model.tf.dcrnn_supervisor import DCRNNSupervisor def main(args): with open(args.config_filename) as f: ...
1,240
32.540541
104
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/run_demo.py
import argparse import numpy as np import os import sys import tensorflow as tf import yaml from lib.utils import load_graph_data from model.tf.dcrnn_supervisor import DCRNNSupervisor def run_dcrnn(args): with open(args.config_filename) as f: config = yaml.load(f) tf_config = tf.ConfigProto() if ...
1,433
36.736842
108
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/scripts/generate_training_data.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import argparse import numpy as np import os import pandas as pd def generate_graph_seq2seq_io_data( df, x_offsets, y_offsets, add_time_in_day=True, add_day_in_...
3,904
30.491935
103
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/scripts/gen_adj_mx.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function import argparse import numpy as np import pandas as pd import pickle def get_adjacency_matrix(distance_df, sensor_ids, normalized_k=0.1): """ :param distance_df: data frame with three columns: [from,...
2,790
42.609375
125
py
Traffic-Benchmark
Traffic-Benchmark-master/methods/ST-MetaNet/scripts/eval_baseline_methods.py
import argparse import numpy as np import pandas as pd from statsmodels.tsa.vector_ar.var_model import VAR from lib import utils from lib.metrics import masked_rmse_np, masked_mape_np, masked_mae_np from lib.utils import StandardScaler def historical_average_predict(df, period=12 * 24 * 7, test_ratio=0.2, null_val=...
5,893
40.507042
116
py