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
transition-amr-parser
transition-amr-parser-master/src/transition_amr_parser/parse.py
# Standalone AMR parser from an existing trained APT model import os import re import time import math import copy import signal import argparse from datetime import timedelta import urllib.request import zipfile from ipdb import set_trace import progressbar from tqdm import tqdm import torch from fairseq import chec...
52,549
34.458839
174
py
transition-amr-parser
transition-amr-parser-master/src/transition_amr_parser/action_pointer/roberta_utils.py
from collections import Counter import torch from spacy.tokens import Doc import copy from fairseq.models.roberta.alignment_utils import spacy_nlp from fairseq.data.data_utils import collate_tokens def get_tokens(roberta, word): return roberta.task.source_dictionary.encode_line(roberta.bpe.encode(word), append_eo...
4,040
38.617647
149
py
transition-amr-parser
transition-amr-parser-master/src/transition_amr_parser/action_pointer/amr_parser.py
# Standalone AMR parser import os import json import torch from transition_amr_parser.model import AMRModel import transition_amr_parser.utils as utils from fairseq.models.roberta import RobertaModel from transition_amr_parser.roberta_utils import extract_features_aligned_to_words class AMRParser(): def __init_...
3,749
42.103448
174
py
transition-amr-parser
transition-amr-parser-master/src/transition_amr_parser/action_pointer/parse.py
# Standalone AMR parser from an existing trained APT model import os import time import math import copy import signal import argparse from datetime import timedelta from ipdb import set_trace from tqdm import tqdm import torch from fairseq import checkpoint_utils, utils from fairseq.models.roberta import RobertaMode...
20,120
35.385172
127
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/binarize.py
import numpy as np import torch from fairseq.data.indexed_dataset import __best_fitting_dtype, MMapIndexedDatasetBuilder, IndexedDatasetBuilder from fairseq.tokenizer import tokenize_line # TODO move this file into data folder def make_builder(out_file, impl, vocab_size=None, dtype=None): if impl == 'mmap': ...
1,100
31.382353
111
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/generate.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate pre-processed data with a trained model. """ import os from collections import defaultdict import torc...
15,450
40.872629
121
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/options_train.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse from typing import Callable, List, Optional import torch from fairseq import utils from fairseq.data.indexed_dataset import g...
20,449
43.360087
123
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/utils.py
import time import math from fairseq.tokenizer import tokenize_line from fairseq.checkpoint_utils import load_checkpoint_to_cpu, torch_persistent_save from fairseq.file_io import PathManager from fairseq.utils import move_to_cpu from fairseq_ext.utils_import import import_user_module # from fairseq_ext.amr_reform.o1...
7,661
38.90625
115
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/average_checkpoints.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import collections import os import re import torch from fairseq.file_io import PathManager def aver...
6,018
37.583333
175
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/sequence_generator_bartsv.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math from copy import deepc...
65,756
50.940758
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/sequence_generator.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math from copy import deepc...
65,291
50.942721
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/options.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse from email.policy import default import torch import sys # from fairseq import utils from fairseq.data.indexed_dataset impor...
31,215
52.088435
123
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/sequence_generator_graph.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math from copy import deepc...
57,973
51.228829
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/generate_sliding.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Translate pre-processed data with a trained model. """ import os from collections import defaultdict import torc...
16,901
43.246073
125
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/sequence_generator_graphmp.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import math from copy import deepc...
62,664
51.615449
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/train.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Train a new model on one or across multiple GPUs. """ import argparse import logging import math import os impor...
23,242
39.848858
125
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/utils_import.py
import os import sys import importlib # ========== adapted from # https://github.com/pytorch/fairseq/blob/83e615d66905b8ca7483122a37da1a85f13f4b8e/fairseq/utils.py#L431 # to avoid error in our setup # ========== def import_user_module(args): module_path = getattr(args, "user_dir", None) if module_path is not ...
1,748
40.642857
104
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/modules/multihead_attention.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from fairseq import utils from fairseq.incr...
23,865
40.65096
114
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/modules/factored_embeddings.py
import re from collections import defaultdict import torch class FactoredEmbeddings(torch.nn.Module): def __init__(self, vocabulary, embed_dim, action_factoring='base'): # register super(FactoredEmbeddings, self).__init__() self.full_to_factor_map, factor_voc_by_pos = \ sel...
6,304
41.033333
95
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/modules/transformer_layer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, List, Optional import torch import torch.nn as nn from fairseq import utils # from fairseq.modules import LayerNorm,...
17,425
39.525581
88
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/modules/multihead_attention_old.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Dict, Optional, Tuple import torch from torch import Tensor, nn from torch.nn import Parameter import torch.nn.functional ...
23,312
45.164356
148
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/modules/transformer_layer_old.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch.nn as nn import torch.nn.functional as F from fairseq import utils # from fairseq.modules import LayerNorm, MultiheadAttention fr...
12,391
41.14966
93
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/criterions/label_smoothed_cross_entropy_pointer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from fairseq import utils from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.criterio...
12,919
45.642599
134
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/criterions/label_smoothed_cross_entropy_pointer_alignment.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch from fairseq import utils from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.criterio...
12,636
50.369919
134
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_bart.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq.mod...
84,503
47.931094
159
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from packaging import version import torch import torch.nn as nn import torch.nn.functional as F from fairseq import options, ut...
79,650
52.709373
147
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_bartsv_sattn.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq.mod...
73,280
46.461788
159
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_graph.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from packaging import version import torch import torch.nn as nn import torch.nn.functional as F from fairseq import options, ut...
64,589
50.343402
147
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_bart_sattn.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq.mod...
79,562
47.161622
159
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_graphmp.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from packaging import version import torch import torch.nn as nn import torch.nn.functional as F from fairseq import options, ut...
84,683
53.38921
147
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/attention_masks.py
from packaging import version import torch def make_bsz_tgt_src_align_mask(tgt_src_cursors, src_max_len, src_pad_mask=None): """Get the batched target-source alignment mask. NOTE The source batch is **left padded**... should be very careful... """ bsz, tgt_max_len = tgt_src_cursors.size() ...
8,953
46.375661
119
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/transformer_tgt_pointer_bartsv.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math from typing import Any, Dict, List, Optional, Tuple import torch import torch.nn as nn from fairseq import utils from fairseq.mod...
75,031
46.821542
159
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/graph_attention_masks.py
"""Decoder self-attention masks, e.g. graph structure.""" from packaging import version import torch def modify_mask_pre_post_softmax(mask): """Modify the attention mask to a pre-softmax mask and a post-softmax mask. The issue is that when one row out of bsz * num_heads (tgt_max_len, src_max_len) masks is fu...
5,741
54.747573
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/models/graphmp_attention_masks.py
"""Decoder self-attention masks, e.g. graph structure for message passing.""" from packaging import version import torch from .graph_attention_masks import modify_mask_pre_post_softmax def get_graph_self_attn_mask(tgt_actedge_masks, tgt_actedge_1stnode_masks, ...
8,485
55.573333
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tests/test_factored_embeddings.py
import torch from fairseq.data import Dictionary from fairseq_ext.modules.factored_embeddings import FactoredEmbeddings if __name__ == '__main__': vocab_path = '/n/tata_ddos_ceph/jzhou/transition-amr-parser-o8/EXP/data/graphmp-swaparc-ptrlast_o8.3_act-states/processed/dict.actions_nopos.txt' embed_dim = 256 ...
546
29.388889
149
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tests/test_composite_embeddings.py
import torch from fairseq.data import Dictionary from fairseq_ext.extract_bart.composite_embeddings import CompositeEmbeddingBART if __name__ == '__main__': vocab_path = '/n/tata_ddos_ceph/jzhou/transition-amr-parser-bart/EXP/data/graphmp-swaparc-ptrlast_o8.3_act-states/processed/dict.actions_nopos.txt' vocab...
1,212
30.102564
151
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tests/test_composite_embeddings_mapping.py
import os from tqdm import tqdm import torch from fairseq.data import Dictionary from fairseq_ext.extract_bart.composite_embeddings import CompositeEmbeddingBART, transform_action_symbol if __name__ == '__main__': vocab_path = '/n/tata_ddos_ceph/jzhou/transition-amr-parser-bart-o10/EXP/data/o10_act-states/proces...
1,056
34.233333
130
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/roberta/binarize_embeddings.py
import numpy as np import torch import shutil import time from ..data import indexed_dataset from ..utils import time_since def dataset_dest_prefix(args, output_prefix, lang): base = "{}/{}".format(args.embdir, output_prefix) lang_part = ( ".{}-{}.{}".format(args.source_lang, args.target_lang, lang) ...
4,761
32.300699
96
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/roberta/pretrained_embeddings_bert.py
import copy import torch from transformers import BertTokenizer, BertModel from ..data.data_utils import collate_tokens from ..utils_font import yellow_font def get_average_embeddings(final_layer, word2piece): # Average worpiece representations to get word representations num_words = len(word2piece) ba...
9,316
35.537255
106
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/roberta/pretrained_embeddings.py
import copy import torch from ..data.data_utils import collate_tokens from ..utils_font import yellow_font def get_average_embeddings(final_layer, word2piece): # Average worpiece representations to get word representations num_words = len(word2piece) batch_dim, num_wordpieces, hidden_size = final_layer...
9,693
36.719844
118
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/extract_bart/binarize_encodings.py
import numpy as np import torch import shutil import time from ..data import indexed_dataset from ..utils import time_since def dataset_dest_prefix(args, output_prefix, lang): base = "{}/{}".format(args.embdir, output_prefix) lang_part = ( ".{}-{}.{}".format(args.source_lang, args.target_lang, lang) ...
6,506
35.971591
115
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/extract_bart/sentence_encoding.py
import copy import torch from ..data.data_utils import collate_tokens from ..utils_font import yellow_font from fairseq_ext.roberta.pretrained_embeddings import PretrainedEmbeddings def get_average_embeddings(final_layer, word2piece): # Average worpiece representations to get word representations num_words...
8,609
35.176471
118
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/extract_bart/composite_embeddings.py
"""Given a base vocabulary and corresponding embeddings, for another vocabulary where elements are composed of sub-elements of the base vocabulary, construct the new embeddings by pooling over the base vocabulary embeddings. """ import torch import torch.nn as nn from torch_scatter import scatter_mean class Composite...
9,588
43.393519
119
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/extract_bart/mapavg_embeddings.py
"""From a list of symbols, get the average embeddings from some base embeddings and a base vocabulary. """ import torch from .composite_embeddings import CompositeEmbedding class MapAvgEmbeddingBART(CompositeEmbedding): def __init__(self, bart, bart_embeddings): super().__init__(bart.task.target_diction...
5,253
38.503759
119
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/amr_spec/action_info_binarize_bartsv.py
import os import itertools from multiprocessing import Pool import time from collections import Counter import torch import numpy as np from tqdm import tqdm from ..amr_reform.o10_action_reformer_subtok import AMRStateMachineSubtoken from .action_info_bartsv import get_actions_states from ..tokenizer import tokenize_...
15,835
40.783641
117
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/amr_spec/action_info_binarize_graphmp_amr1.py
import os import itertools from multiprocessing import Pool import time from collections import Counter import torch import numpy as np from transition_amr_parser.action_pointer.o8_state_machine import AMRStateMachine from .action_info_graphmp_amr1 import get_actions_states from ..tokenizer import tokenize_line_tab f...
21,411
43.888889
117
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/amr_spec/action_info_binarize_graphmp.py
import os import itertools from multiprocessing import Pool import time from collections import Counter import torch import numpy as np from transition_amr_parser.action_pointer.o8_state_machine import AMRStateMachine from .action_info_graphmp import get_actions_states from ..tokenizer import tokenize_line_tab from ....
21,406
43.878407
117
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/amr_spec/action_info_binarize.py
import os import itertools from multiprocessing import Pool import time from collections import Counter import torch import numpy as np from tqdm import tqdm from transition_amr_parser.amr_machine import AMRStateMachine from .action_info import get_actions_states from ..tokenizer import tokenize_line_tab from ..binar...
15,698
40.531746
117
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/amr_spec/old_action_info_binarize.py
import os import itertools from multiprocessing import Pool import time import torch import numpy as np from tqdm import tqdm from transition_amr_parser.action_pointer.o8_state_machine import AMRStateMachine from .action_info import get_actions_states from ..tokenizer import tokenize_line_tab from ..binarize import m...
28,857
49.451049
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/language_pair_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from fairseq.data import FairseqDataset from fairseq_ext.data import data_utils from fairseq_ext.data.data_u...
18,120
40.466819
106
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/amr_bpe.py
"""BART GPT2 BPE encoder for tokenization with added AMR special action symbols. """ import json from pathlib import Path from typing import List, Union, Tuple import regex as re from fairseq import file_utils from fairseq.data.encoders.gpt2_bpe_utils import Encoder from fairseq.data.dictionary import Dictionary impor...
10,917
41.15444
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/amr_action_pointer_graphmp_dataset.py
import numpy as np import torch from fairseq.data import FairseqDataset from fairseq_ext.data.data_utils import ( collate_embeddings, collate_wp_idx, # collate_target_masks, # collate_masks ) from fairseq_ext.data import data_utils def collate( samples, pad_idx, eos_idx, left_pad_source=True, lef...
30,770
46.855365
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/data_utils.py
import itertools import torch def collate_embeddings(values, pad_idx, eos_idx=None, left_pad=False, move_eos_to_beginning=False): """Convert a list of 1d tensors into a padded 2d tensor.""" # longest sentence size size = max(v.size(0) for v in values) # embedding size emb_dim = list(set(v.size(1...
9,147
34.320463
129
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/indexed_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from functools import lru_cache import os import shutil import struct import numpy as np import torch from fairseq.data import FairseqDatase...
16,218
29.776091
108
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/amr_action_pointer_goldamr_dataset.py
import numpy as np import torch from fairseq.data import FairseqDataset from fairseq_ext.data.data_utils import ( collate_embeddings, collate_wp_idx, # collate_target_masks, # collate_masks ) from fairseq_ext.data import data_utils def collate( samples, pad_idx, eos_idx, left_pad_source=True, lef...
30,695
45.159398
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/amr_action_pointer_dataset.py
import numpy as np import torch from fairseq.data import FairseqDataset from fairseq_ext.data.data_utils import ( collate_embeddings, collate_wp_idx, # collate_target_masks, # collate_masks ) from fairseq_ext.data import data_utils def collate( samples, pad_idx, eos_idx, left_pad_source=True, lef...
29,892
45.345736
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/data/amr_action_pointer_bartsv_dataset.py
import numpy as np import torch from fairseq.data import FairseqDataset from fairseq_ext.data.data_utils import ( collate_embeddings, collate_wp_idx, # collate_target_masks, # collate_masks ) from fairseq_ext.data import data_utils def collate( samples, pad_idx, eos_idx, left_pad_source=True, lef...
29,683
45.453834
124
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer_graphmp_amr1.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
24,616
48.731313
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer_bart_dyo.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import ...
55,372
44.687294
128
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer_graphmp.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
24,602
48.70303
120
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer_bartsv.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
28,086
47.932056
128
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
22,251
46.853763
118
py
transition-amr-parser
transition-amr-parser-master/src/fairseq_ext/tasks/amr_action_pointer_bart.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import itertools import os import...
27,439
47.480565
128
py
transition-amr-parser
transition-amr-parser-master/scripts/Blinker.py
import sys import os import glob import argparse import torch.cuda import importlib.util import logging import string import json import numpy import random import hashlib MENTIONSTART = '[unused1]' MENTIONEND = '[unused2]' CONTEXTLEFTKEY = 'context_left' CONTEXTRIGHTKEY = 'context_right' MENTIONKEY = 'mention' CACHE...
18,796
31.690435
150
py
transition-amr-parser
transition-amr-parser-master/tests/correctly_installed.py
import torch import subprocess # from ipdb import set_trace def main(): # Pytorch and CUDA passed = True print() import torch print(f'pytorch {torch.__version__}') if torch.cuda.is_available(): print(f'cuda {torch.version.cuda}') # happens when CUDA missconfigured asse...
1,918
24.932432
65
py
transition-amr-parser
transition-amr-parser-master/run/status.py
import sys import shutil from time import sleep import numpy as np from glob import glob import signal import re import os from datetime import datetime import argparse from collections import defaultdict, Counter from statistics import mean from transition_amr_parser.io import read_config_variables from transition_amr...
41,853
32.323248
82
py
nfm
nfm-master/experiment_synthesis.py
import torch import numpy as np import torch.nn as nn import matplotlib.pyplot as plt from tqdm import tqdm from torch.utils.data import DataLoader from nfm.base import TransNLL, MonotoneNLL from nfm.eps_config import ParetoEps from nfm.synthesis import * torch.manual_seed(88888888) sample_size = 5000 d = 5 censor_...
2,775
31.658824
109
py
nfm
nfm-master/experiment_metabric_pf.py
import torch import numpy as np import pandas as pd import torch.nn as nn from tqdm import tqdm from torch.utils.data import DataLoader from nfm.datasets import SurvivalDataset from nfm.base import MonotoneNLL from nfm.eps_config import IGGEps from nfm.metric import c_index from nfm.utils import default_device from pyc...
3,577
38.755556
118
py
nfm
nfm-master/experiment_metabric_fn.py
import torch import numpy as np import pandas as pd import torch.nn as nn from tqdm import tqdm from torch.utils.data import DataLoader from nfm.datasets import SurvivalDataset from nfm.base import FullyNeuralNLL from nfm.eps_config import ParetoEps from pycox.evaluation.eval_surv import EvalSurv class Net(nn.Module)...
3,461
37.898876
98
py
nfm
nfm-master/nfm/base.py
import torch import torch.nn as nn from .umnn import UMNN from .umnn_v2 import ParallelNeuralIntegral, _flatten from .utils import default_device class EpsDistribution(object): """Abstraction of (univariate) distribution of epsilon, shall be differentiable and vectorized Currently we don't allow the configura...
7,405
39.917127
103
py
nfm
nfm-master/nfm/umnn_v2.py
# Actually the original impl of UMNN import torch import numpy as np import math def _flatten(sequence): flat = [p.contiguous().view(-1) for p in sequence] return torch.cat(flat) if len(flat) > 0 else torch.tensor([]) def compute_cc_weights(nb_steps): lam = np.arange(0, nb_steps + 1, 1).reshape(-1, 1) ...
3,963
38.247525
138
py
nfm
nfm-master/nfm/synthesis.py
import torch import torch.utils.data as data import torch.nn.functional as F __all__ = ('IdentityH', 'ExponentialH', 'M', 'Z', 'Noise', 'SyntheticData', 'PFSyntheticData') class GenericH(object): """Configuration for oracle H, used in proportional frailty models""" def __call__(self, x: torch.Tensor) -> to...
4,256
27.192053
94
py
nfm
nfm-master/nfm/umnn.py
# Implemntations adapted from UMNN's official libray at # https://github.com/AWehenkel/UMNN import torch import math import numpy as np import torch.nn as nn import torch.nn.functional as F from torch.nn import init from .utils import default_device def _flatten(sequence): flat = [p.contiguous().view(-1) for p in...
5,085
35.070922
119
py
nfm
nfm-master/nfm/utils.py
import torch _ALLOW_MPS = False def get_default_device(): if not torch.cuda.is_available(): if _ALLOW_MPS: try: device = torch.device('mps') except BaseException as inst: device = torch.device('cpu') else: device = torch.device(...
436
18
44
py
nfm
nfm-master/nfm/datasets.py
import os import torch import h5py import numpy as np import pandas as pd import torch.nn.functional as F from torch.utils.data import Dataset from .utils import default_device from pycox.datasets import kkbox_v1 as kkbox class SurvivalDataset(Dataset): """Interface of survival datasets """ @classmethod ...
11,320
43.396078
136
py
nfm
nfm-master/nfm/eps_config.py
import torch import torch.nn as nn import torch.nn.functional as F from .base import EpsDistribution class GaussianEps(EpsDistribution): """As-is""" def __init__(self): self._gaussian_rv = torch.distributions.Normal(0., 1.) def hazard(self, x): return torch.exp(self._gaussian_rv.log_prob...
5,660
30.983051
110
py
nfm
nfm-master/nfm/metric.py
import torch import numba import numpy as np def c_index(y_pred, y_true, delta): """implementation of the concordance index, essentially a censoring-compatible version of Kendall's tau Args: y_pred(torch.Tensor): predicted survival upto monotone transforms, with shape [batch_size, 1] y_true(t...
1,333
32.35
107
py
MTFuzz
MTFuzz-master/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,598
50.130226
240
py
MTFuzz
MTFuzz-master/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,020
34.420857
163
py
MTFuzz
MTFuzz-master/programs/hb-fuzzer/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,268
50.114246
240
py
MTFuzz
MTFuzz-master/programs/hb-fuzzer/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="1" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,645
34.398198
163
py
MTFuzz
MTFuzz-master/programs/djpeg/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,273
50.117688
240
py
MTFuzz
MTFuzz-master/programs/djpeg/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="2" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import shutil import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as...
19,702
34.310036
174
py
MTFuzz
MTFuzz-master/programs/readelf/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,267
50.113558
240
py
MTFuzz
MTFuzz-master/programs/readelf/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="1" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,328
34.20765
163
py
MTFuzz
MTFuzz-master/programs/nm/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,268
50.114246
240
py
MTFuzz
MTFuzz-master/programs/nm/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,328
34.20765
163
py
MTFuzz
MTFuzz-master/programs/mutool/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,272
50.116999
240
py
MTFuzz
MTFuzz-master/programs/mutool/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
15,743
33.151844
163
py
MTFuzz
MTFuzz-master/programs/xmllint/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,268
50.114246
240
py
MTFuzz
MTFuzz-master/programs/xmllint/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="1" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,679
34.332136
163
py
MTFuzz
MTFuzz-master/programs/miniunz/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,272
50.116999
240
py
MTFuzz
MTFuzz-master/programs/miniunz/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
15,787
33.17316
175
py
MTFuzz
MTFuzz-master/programs/objdump/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,278
50.121129
240
py
MTFuzz
MTFuzz-master/programs/objdump/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="2" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import shutil import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as...
19,698
34.302867
174
py
MTFuzz
MTFuzz-master/programs/size/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,268
50.114246
240
py
MTFuzz
MTFuzz-master/programs/size/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,020
34.420857
163
py
MTFuzz
MTFuzz-master/programs/strip/mtfuzz_wrapper.py
import subprocess import sys import math import shutil import subprocess import glob import ipdb import pickle import os import numpy as np import struct import time FNULL = open(os.devnull, 'w') mut_cnt = 0 ''' def train(x, y): model = Sequential() model.add(Dense(8, input_dim=x.shape[1])) #model.add(Dense...
74,268
50.114246
240
py
MTFuzz
MTFuzz-master/programs/strip/nn.py
import pickle import os os.environ["CUDA_VISIBLE_DEVICES"]="0" os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import sys import glob import math import time from functools import partial import keras import random import socket import subprocess import numpy as np import tensorflow as tf import keras.backend as K from collec...
19,328
34.20765
163
py
DPSN
DPSN-master/time_series_proto/lib/models/feature_transformer.py
import torch import torch.nn as nn from .initialization import init_kaiming class linear_transform(nn.Module): def __init__(self, fea_dim, hidden_dim=2048, out_dim=2048): super(linear_transform, self).__init__() self.fc1 = nn.Linear(fea_dim, hidden_dim) self.dp = nn.Dropout(p=0.5) self.fc2 = nn.Linea...
1,001
26.833333
62
py