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 |
|---|---|---|---|---|---|---|
pycbc | pycbc-master/bin/plotting/pycbc_plot_Nth_loudest_coinc_omicron.py | """
Generates a plot that shows the time-frequency trace of
Nth loudest coincident trigger overlaid on a background of
Omicron triggers.
"""
import logging
import h5py
import numpy as np
import argparse
import glob
from ligo.lw import lsctables, utils
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as... | 6,224 | 39.16129 | 102 | py |
pycbc | pycbc-master/test/test_correlate.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 3,141 | 35.534884 | 85 | py |
pycbc | pycbc-master/test/test_significance_module.py | """Unit test for converting sets of statistic values into significances."""
import unittest
import argparse
import itertools
import copy
import numpy as np
from utils import simple_exit
from pycbc.events import significance
def parse_args(args):
# Helper function to convert a list of flags/options into
# an a... | 7,904 | 37.188406 | 75 | py |
pycbc | pycbc-master/test/test_conversions.py | import numpy
from pycbc import coordinates
from pycbc import distributions
from pycbc import conversions
import unittest
from utils import simple_exit
seed = 8202
numpy.random.seed(seed)
def almost_equal(derived_val, check_val, precision=1e-8):
"""Checks whether the difference in the derived and check values are ... | 9,562 | 49.068063 | 96 | py |
pycbc | pycbc-master/test/test_frame.py | # Copyright (C) 2012 Andrew Miller, Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This p... | 6,510 | 41.279221 | 96 | py |
pycbc | pycbc-master/test/test_threshold.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 2,341 | 35.59375 | 79 | py |
pycbc | pycbc-master/test/test_coinc_stat.py | """Unit test for coincident ranking statistic implementations."""
import unittest
import numpy as np
from utils import parse_args_cpu_only, simple_exit
from pycbc.events.stat import statistic_dict
# this test only needs to happen on the CPU
parse_args_cpu_only('coinc stats')
class CoincStatTest(unittest.TestCase):
... | 2,919 | 35.5 | 80 | py |
pycbc | pycbc-master/test/test_chisq.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 4,885 | 35.736842 | 79 | py |
pycbc | pycbc-master/test/test_waveform.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 7,464 | 51.570423 | 236 | py |
pycbc | pycbc-master/test/test_timeseries.py | # Copyright (C) 2012 Alex Nitz, Andrew Miller, Josh Willis, Tito Dal Canton
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later ve... | 26,161 | 42.749164 | 122 | py |
pycbc | pycbc-master/test/test_waveform_utils.py | import unittest
import numpy
from utils import simple_exit
from pycbc.waveform.utils import apply_fd_time_shift
from pycbc.types import (TimeSeries)
class TestFDTimeShift(unittest.TestCase):
"""Tests ``apply_fd_time_shift``."""
def setUp(self):
# we'll use a sine wave time series to do the testing, ... | 4,561 | 40.853211 | 78 | py |
pycbc | pycbc-master/test/test_fftw_openmp.py | # Copyright (C) 2012 Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is d... | 2,496 | 31.855263 | 94 | py |
pycbc | pycbc-master/test/test_noise.py | # Copyright (C) 2019 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the... | 2,721 | 35.783784 | 79 | py |
pycbc | pycbc-master/test/test_fft_mkl_threaded.py | # Copyright (C) 2012 Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is d... | 2,447 | 33 | 79 | py |
pycbc | pycbc-master/test/test_calibration.py | import unittest
from pycbc import strain
from pycbc.types import FrequencySeries
import numpy as np
from pycbc.workflow.configuration import WorkflowConfigParser
from pycbc.strain.recalibrate import Recalibrate
from utils import simple_exit
def strain_array():
frequency_array = np.linspace(0, 2048, 100)
delta... | 2,989 | 38.342105 | 81 | py |
pycbc | pycbc-master/test/utils.py | # Copyright (C) 2012--2013 Alex Nitz, Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# ... | 38,174 | 43.235226 | 105 | py |
pycbc | pycbc-master/test/test_pnutils.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 4,562 | 42.04717 | 85 | py |
pycbc | pycbc-master/test/test_psd.py | # Copyright (C) 2012 Tito Dal Canton, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is... | 5,913 | 43.134328 | 97 | py |
pycbc | pycbc-master/test/test_io_live.py | # Copyright (C) 2018 Tito Dal Canton
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed i... | 6,282 | 34.902857 | 77 | py |
pycbc | pycbc-master/test/test_dq.py | # Copyright (C) 2019 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the... | 5,132 | 42.5 | 100 | py |
pycbc | pycbc-master/test/test_array_lal.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 5,083 | 41.722689 | 95 | py |
pycbc | pycbc-master/test/test_fft_unthreaded.py | # Copyright (C) 2012 Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is d... | 2,475 | 33.388889 | 79 | py |
pycbc | pycbc-master/test/bankvetotest.py | from pycbc.types import *
from pycbc.noise.gaussian import *
from pycbc.filter import *
from pycbc.waveform import *
from pycbc.vetoes import *
import pycbc.psd
sr = 4096.0
dt = 1.0/sr
bl = 256
df = 1.0/bl
N = int(sr * bl)
n = int(N/2 + 1)
psd = pycbc.psd.from_string("aLIGOZeroDetHighPower", n, df, 14)
strain = noise... | 3,650 | 38.258065 | 103 | py |
pycbc | pycbc-master/test/test_distributions.py | # Copyright (C) 2017 Christopher M. Biwer
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distribu... | 11,170 | 40.838951 | 79 | py |
pycbc | pycbc-master/test/test_autochisq.py | from pycbc.fft.fftw import set_measure_level
set_measure_level(0)
from pycbc.filter import matched_filter_core
from pycbc.types import Array, TimeSeries, FrequencySeries
from pycbc.waveform import *
from pycbc.vetoes import *
import numpy as np
from math import cos, sin, pi, exp
import unittest
from utils import parse... | 6,519 | 32.265306 | 105 | py |
pycbc | pycbc-master/test/test_resample.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 3,646 | 37.797872 | 94 | py |
pycbc | pycbc-master/test/lalsim.py | # Copyright (C) 2013 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the... | 16,620 | 38.016432 | 143 | py |
pycbc | pycbc-master/test/test_injection.py | # Copyright (C) 2013 Tito Dal Canton, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is ... | 6,986 | 39.859649 | 84 | py |
pycbc | pycbc-master/test/test_array.py | # Copyright (C) 2012 Alex Nitz, Andrew Miller, Tito Dal Canton, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later ve... | 21,211 | 39.636015 | 122 | py |
pycbc | pycbc-master/test/test_cuts.py | """
Unit tests for cuts being applied to trigger and templates
"""
import unittest
import argparse
import copy
import numpy as np
from utils import simple_exit
from pycbc.events import cuts, ranking
from pycbc.tmpltbank import bank_conversions
def parse_args(args):
# Helper function to convert a list of flags/op... | 8,904 | 34.907258 | 78 | py |
pycbc | pycbc-master/test/test_schemes.py | # Copyright (C) 2012 Alex Nitz, Andrew Miller, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This p... | 7,707 | 40.219251 | 87 | py |
pycbc | pycbc-master/test/test_frequencyseries.py | # Copyright (C) 2012 Alex Nitz, Andrew Miller, Tito Dal Canton, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later ve... | 24,440 | 43.277174 | 122 | py |
pycbc | pycbc-master/test/test_transforms.py | # Copyright (C) 2017 Christopher M. Biwer
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distribu... | 3,458 | 33.59 | 79 | py |
pycbc | pycbc-master/test/test_detector.py | # Copyright (C) 2018 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the ... | 4,019 | 34.892857 | 95 | py |
pycbc | pycbc-master/test/test_matchedfilter.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 9,715 | 39.14876 | 93 | py |
pycbc | pycbc-master/test/test_infmodel.py | # Copyright (C) 2021 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the ... | 7,338 | 40.463277 | 82 | py |
pycbc | pycbc-master/test/test_fftw_pthreads.py | # Copyright (C) 2012 Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is d... | 2,442 | 32.465753 | 98 | py |
pycbc | pycbc-master/test/fft_base.py | # Copyright (C) 2012 Josh Willis, Andrew Miller
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is d... | 37,722 | 47.737726 | 101 | py |
pycbc | pycbc-master/test/test_spatmplt.py | # Copyright (C) 2012 Alex Nitz, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distr... | 3,434 | 41.9375 | 128 | py |
pycbc | pycbc-master/test/test_tmpltbank.py | # Copyright (C) 2013 Ian Harry
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the ... | 26,607 | 45.84507 | 87 | py |
pycbc | pycbc-master/test/test_skymax.py | import copy
import unittest
import random
import os
import numpy
from numpy import complex128, real, sqrt, sin, cos, angle, ceil, log
from numpy import zeros, argmax, array
from astropy.utils.data import download_file
from pycbc import DYN_RANGE_FAC
from pycbc.waveform import get_td_waveform, get_fd_waveform, td_approx... | 19,047 | 40.680525 | 94 | py |
pycbc | pycbc-master/test/test_live_coinc_compare.py | """Mock simulation to easily test and profile PyCBC Live's coincidence code."""
import unittest
from types import SimpleNamespace
import numpy as np
# Some duplicate imports, but I want to copy code without changing it!
import numpy, logging, pycbc.pnutils, pycbc.conversions, copy, lal
import cProfile
from astropy.uti... | 6,818 | 37.965714 | 110 | py |
pycbc | pycbc-master/test/validation_code/old_stat.py | # Copyright (C) 2016 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the ... | 78,377 | 36.62746 | 81 | py |
pycbc | pycbc-master/test/validation_code/__init__.py | 0 | 0 | 0 | py | |
pycbc | pycbc-master/test/validation_code/old_coinc.py | # Copyright (C) 2015 Alex Nitz
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the ... | 44,282 | 37.506957 | 99 | py |
pycbc | pycbc-master/docs/remove_non_standard_imports.py | #!/usr/bin/env python
# Copyright (C) 2011 Ian W. Harry
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This prog... | 2,021 | 30.59375 | 76 | py |
pycbc | pycbc-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# PyCBC documentation build configuration file, created by
# sphinx-quickstart on Tue Jun 11 17:02:52 2013.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All c... | 11,336 | 31.484241 | 132 | py |
pycbc | pycbc-master/docs/_include/waveform-parameters.py | #!/usr/bin/env python
# Copyright (C) 2018 Duncan Macleod, Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later versi... | 1,478 | 35.073171 | 75 | py |
pycbc | pycbc-master/docs/_include/inference_data_opts-table.py | #!/usr/bin/env python
# Copyright (C) 2020 Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This pro... | 10,089 | 33.913495 | 79 | py |
pycbc | pycbc-master/docs/_include/_dict_to_rst.py | # Copyright (C) 2018 Duncan Macleod
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in... | 4,090 | 29.992424 | 85 | py |
pycbc | pycbc-master/docs/_include/distributions-table.py | #!/usr/bin/env python
# Copyright (C) 2018 Duncan Macleod, Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later versi... | 1,217 | 37.0625 | 75 | py |
pycbc | pycbc-master/docs/_include/transforms-table.py | #!/usr/bin/env python
# Copyright (C) 2018 Duncan Macleod, Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later versi... | 1,215 | 37 | 75 | py |
pycbc | pycbc-master/docs/_include/models-table.py | #!/usr/bin/env python
# Copyright (C) 2018 Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This pro... | 1,199 | 36.5 | 75 | py |
pycbc | pycbc-master/docs/_include/sampler_inheritance_diagrams.py | # Creates RST for the sampler inheritance diagrams
from pycbc.inference.sampler import samplers
fname = 'sampler_inheritance_diagrams.rst'
tmplt = """.. _inheritance-{name}:
* ``{name}``:
.. inheritance-diagram:: {module}.{clsname}
:parts: 3
|
"""
fp = open(fname, 'w')
for sampler, cls in sorted(samplers.items... | 466 | 19.304348 | 58 | py |
pycbc | pycbc-master/docs/_include/samplers-table.py | #!/usr/bin/env python
# Copyright (C) 2018 Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This pro... | 1,196 | 36.40625 | 75 | py |
pycbc | pycbc-master/docs/_include/inference_io_inheritance_diagrams.py | # Creates RST for the sampler inheritance diagrams
import inspect
from pycbc.inference.io import filetypes
fname = 'inference_io_inheritance_diagrams.rst'
def get_topclasses(cls):
"""Gets the base classes that are in pycbc."""
bases = [c for c in inspect.getmro(cls)
if c.__module__.startswith('py... | 871 | 24.647059 | 79 | py |
pycbc | pycbc-master/docs/_include/psd_models-table.py | #!/usr/bin/env python
# Copyright (C) 2020 Collin Capano
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This pro... | 1,243 | 32.621622 | 75 | py |
MAPS-mt | MAPS-mt-main/interactive.py | import os
import difflib
import logging
import argparse
import warnings
from typing import List
from langcodes import Language
from data.trigger_sents import SUPPORT_LANGS
from comet import load_from_checkpoint, download_model
from data import demo_ex_dict, kw_ex_dict, topic_ex_dict
from model.openai.translate import a... | 10,309 | 41.780083 | 186 | py |
MAPS-mt | MAPS-mt-main/scripts/score.py | import os
import argparse
from comet import load_from_checkpoint, download_model
import os
import json
import threading
from bleurt import score as bleurt_score
import logging
from sacrebleu.metrics import BLEU
comet_model_mapping = {
"wmt21-comet-qe-da": "wmt21-comet-qe-da/checkpoints/model.ckpt",
}
def wait_unt... | 11,174 | 37.402062 | 155 | py |
MAPS-mt | MAPS-mt-main/scripts/knowledge-selection.py | import os
import torch
import json
import random
import logging
import argparse
import threading
import numpy as np
from sacrebleu.metrics import BLEU
from comet import load_from_checkpoint, download_model
comet_model_mapping = {
"wmt21-comet-qe-da": "wmt21-comet-qe-da/checkpoints/model.ckpt",
}
def seed_everythi... | 9,515 | 36.027237 | 155 | py |
MAPS-mt | MAPS-mt-main/scripts/alpaca-post-process.py | #! /usr/bin/python
import sys
import re
import os
all_langs = []
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "lang.list"), 'r') as reader:
for sample in reader:
lang, code = sample.strip().split('\t')
all_langs.append(lang)
if '(' in lang:
lang = lang[:la... | 1,574 | 31.8125 | 146 | py |
MAPS-mt | MAPS-mt-main/scripts/compare.py | import os
from comet.cli.compare import *
import threading
import logging
from bleurt import score as bleurt_score
from sacrebleu.metrics import BLEU
comet_model_mapping = {
"wmt21-comet-qe-da": "wmt21-comet-qe-da/checkpoints/model.ckpt",
}
def wait_until_path_exist(path):
while not os.path.isdir(path):
... | 17,345 | 34.4 | 155 | py |
MAPS-mt | MAPS-mt-main/data/format_ask_demo.py | import random
import os
from langcodes import Language
import argparse
from .trigger_sents import SUPPORT_LANGS, TRIGGER_SENTS
DEMO_SENTS = {
"en": [
"Around the same time, Patrick Brown, a professor of biochemistry at Stanford University School of Medicine, became interested in developing new techniques f... | 6,098 | 56 | 235 | py |
MAPS-mt | MAPS-mt-main/data/format_ask_topic.py | import random
import os
from langcodes import Language
import argparse
from .trigger_sents import SUPPORT_LANGS, TRIGGER_SENTS
TOPICS = [
"Health, medicine"
"Accident, aircraft crash"
"Sports, spanish football"
"Politics"
"Business"
],
demo_dict = {}
for src_lng in SUPPORT_LANGS:
for tgt_lng i... | 2,698 | 34.051948 | 148 | py |
MAPS-mt | MAPS-mt-main/data/format_ask_kw.py | import random
import os
from langcodes import Language
import argparse
from .trigger_sents import SUPPORT_LANGS, TRIGGER_SENTS
KETWORDS = {
"en": [
["Stanford University", "School of Medicine"],
["JAS 39C Gripen", "commercial flights"],
["Barça", "Sevilla"],
["Whitehall", "Downing S... | 3,916 | 35.95283 | 148 | py |
MAPS-mt | MAPS-mt-main/data/format_base.py | import random
import os
from langcodes import Language
import argparse
def parse_args():
parser = argparse.ArgumentParser("", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-w', "--workspace", type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'), help="... | 3,015 | 39.213333 | 148 | py |
MAPS-mt | MAPS-mt-main/data/format_kw.py | import random
import os
from langcodes import Language
import argparse
def parse_args():
parser = argparse.ArgumentParser("", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-w', "--workspace", type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'), help="... | 2,724 | 41.578125 | 148 | py |
MAPS-mt | MAPS-mt-main/data/__init__.py | from .format_ask_demo import demo_dict as demo_ex_dict
from .format_ask_kw import demo_dict as kw_ex_dict
from .format_ask_topic import demo_dict as topic_ex_dict | 162 | 53.333333 | 56 | py |
MAPS-mt | MAPS-mt-main/data/format_topic.py | import random
import os
from langcodes import Language
import argparse
def parse_args():
parser = argparse.ArgumentParser("", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-w', "--workspace", type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'), help="... | 2,747 | 41.9375 | 148 | py |
MAPS-mt | MAPS-mt-main/data/format_demo.py | import random
import os
from langcodes import Language
import argparse
def parse_args():
parser = argparse.ArgumentParser("", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-w', "--workspace", type=str, default=os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'), help="... | 2,774 | 43.047619 | 148 | py |
MAPS-mt | MAPS-mt-main/data/trigger_sents.py | TRIGGER_SENTS = {
"en": [
"On Monday, scientists from the Stanford University School of Medicine announced the invention of a new diagnostic tool that can sort cells by type: a tiny printable chip that can be manufactured using standard inkjet printers for possibly about one U.S. cent each.",
"The J... | 3,564 | 92.815789 | 376 | py |
MAPS-mt | MAPS-mt-main/model/__init__.py | 0 | 0 | 0 | py | |
MAPS-mt | MAPS-mt-main/model/openai/translate.py | import os
import re
import openai
import argparse
import tiktoken
from tqdm import tqdm
import backoff
api_key = "YOUR OPENAI API KEY"
model2max_context = {
"text-davinci-003": 4097,
}
class OutOfQuotaException(Exception):
"Raised when the key exceeded the current quota"
def __init__(self, key, cause=Non... | 5,776 | 34.22561 | 199 | py |
MAPS-mt | MAPS-mt-main/model/openai/__init__.py | 0 | 0 | 0 | py | |
MAPS-mt | MAPS-mt-main/model/alpaca/translate.py | import os
import re
import torch
import argparse
from tqdm import tqdm
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--seed', type=int, default=0)
parser.add_argument('--model-name-or-path', ... | 4,295 | 44.221053 | 128 | py |
MAPS-mt | MAPS-mt-main/model/alpaca/__init__.py | 0 | 0 | 0 | py | |
keepalived | keepalived-master/tools/json_tracking/make_conf.py | #!/usr/bin/env python3
#####
#
# This script will generate a sample configuration for Keepalived.
# The configuration is as follows:
# Each vlan contains a VRRPv2 instance with a private IPv4 address
# and a VRRPv3 instance with a Local Address.
# Each instance tracks a file located in keepalived_offset_folder.
#
# Au... | 1,819 | 27.888889 | 74 | py |
keepalived | keepalived-master/doc/source/conf.py | # -*- coding: utf-8 -*-
#
# Keepalived documentation build configuration file, created by
# sphinx-quickstart on Mon Dec 29 18:59:45 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
... | 9,456 | 30.734899 | 80 | py |
UNIXKD | UNIXKD-master/teacher.py | import os
import os.path as osp
import argparse
import time
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import MultiStepLR
from torch.utils.data import DataLoader
import torchvision.transforms as transforms
from torchv... | 5,083 | 33.821918 | 110 | py |
UNIXKD | UNIXKD-master/utils.py | import os
import logging
import numpy as np
import time
import torch
from torch.nn import init
import torch.nn.functional as F
import torch.utils.data as data
from PIL import Image
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
... | 2,691 | 24.638095 | 87 | py |
UNIXKD | UNIXKD-master/zoo.py | from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
"""Paying More Attention to Attention: Improving the Performance of Convolutional Neural Networks
via Attention Transfer
code: https://github.com/szagoruyko/attention-transf... | 1,745 | 30.178571 | 101 | py |
UNIXKD | UNIXKD-master/student_v0.py | import os
import os.path as osp
import argparse
import time
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torch.optim.lr_scheduler import MultiStepLR
import torchvision.transforms as transforms
from tensor... | 9,632 | 36.628906 | 101 | py |
UNIXKD | UNIXKD-master/dataset/utils.py | import os
import os.path
import hashlib
import gzip
import errno
import tarfile
import zipfile
import torch
from torch.utils.model_zoo import tqdm
def gen_bar_updater():
pbar = tqdm(total=None)
def bar_update(count, block_size, total_size):
if pbar.total is None and total_size:
pbar.tota... | 8,765 | 29.975265 | 109 | py |
UNIXKD | UNIXKD-master/dataset/__init__.py | from .cifar import CIFAR100, CIFAR10
| 37 | 18 | 36 | py |
UNIXKD | UNIXKD-master/dataset/vision.py | import os
import torch
import torch.utils.data as data
class VisionDataset(data.Dataset):
_repr_indent = 4
def __init__(self, root, transforms=None, transform=None, target_transform=None):
if isinstance(root, torch._six.string_classes):
root = os.path.expanduser(root)
self.root = ... | 2,950 | 35.432099 | 86 | py |
UNIXKD | UNIXKD-master/dataset/cifar.py | from PIL import Image
import os
import os.path
import numpy as np
import pickle
from .vision import VisionDataset
from .utils import check_integrity, download_and_extract_archive
class CIFAR10(VisionDataset):
"""`CIFAR10 <https://www.cs.toronto.edu/~kriz/cifar.html>`_ Dataset.
Args:
root (string): Ro... | 5,819 | 34.272727 | 99 | py |
UNIXKD | UNIXKD-master/models/resnet.py | from __future__ import absolute_import
'''Resnet for cifar dataset.
Ported form
https://github.com/facebook/fb.resnet.torch
and
https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py
(c) YANG, Wei
'''
import torch.nn as nn
import torch.nn.functional as F
import math
__all__ = ['resnet']
def con... | 7,841 | 29.161538 | 116 | py |
UNIXKD | UNIXKD-master/models/mobilenetv2.py | """
MobileNetV2 implementation used in
<Knowledge Distillation via Route Constrained Optimization>
"""
import torch
import torch.nn as nn
import math
__all__ = ['mobilenetv2_T_w', 'mobile_half']
BN = None
def conv_bn(inp, oup, stride):
return nn.Sequential(
nn.Conv2d(inp, oup, 3, stride, 1, bias=False)... | 5,777 | 27.323529 | 115 | py |
UNIXKD | UNIXKD-master/models/vgg.py | '''VGG for CIFAR10. FC layers are removed.
(c) YANG, Wei
'''
import torch.nn as nn
import torch.nn.functional as F
import math
__all__ = [
'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn',
'vgg19_bn', 'vgg19',
]
model_urls = {
'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30... | 6,971 | 28.417722 | 98 | py |
UNIXKD | UNIXKD-master/models/classifier.py | from __future__ import print_function
import torch.nn as nn
#########################################
# ===== Classifiers ===== #
#########################################
class LinearClassifier(nn.Module):
def __init__(self, dim_in, n_label=10):
super(LinearClassifier, self).__init__()
self.n... | 819 | 21.777778 | 51 | py |
UNIXKD | UNIXKD-master/models/resnetv2.py | '''ResNet in PyTorch.
For Pre-activation ResNet, see 'preact_resnet.py'.
Reference:
[1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
Deep Residual Learning for Image Recognition. arXiv:1512.03385
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion... | 6,915 | 33.753769 | 106 | py |
UNIXKD | UNIXKD-master/models/ShuffleNetv1.py | '''ShuffleNet in PyTorch.
See the paper "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups):
super(ShuffleBlock, self).__init_... | 4,732 | 33.05036 | 126 | py |
UNIXKD | UNIXKD-master/models/util.py | from __future__ import print_function
import torch.nn as nn
import math
class Paraphraser(nn.Module):
"""Paraphrasing Complex Network: Network Compression via Factor Transfer"""
def __init__(self, t_shape, k=0.5, use_bn=False):
super(Paraphraser, self).__init__()
in_channel = t_shape[1]
... | 9,622 | 32.068729 | 107 | py |
UNIXKD | UNIXKD-master/models/ShuffleNetv2.py | '''ShuffleNetV2 in PyTorch.
See the paper "ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design" for more details.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class ShuffleBlock(nn.Module):
def __init__(self, groups=2):
super(ShuffleBlock, self).__init__()
... | 7,074 | 32.530806 | 107 | py |
UNIXKD | UNIXKD-master/models/__init__.py | from .resnet import resnet8, resnet14, resnet20, resnet32, resnet44, resnet56, resnet110, resnet8x4, resnet32x4, resnet14x4
from .resnetv2 import ResNet18, ResNet34, ResNet50
from .wrn import wrn_16_1, wrn_16_2, wrn_40_1, wrn_40_2
from .vgg import vgg19_bn, vgg16_bn, vgg13_bn, vgg11_bn, vgg8_bn
from .mobilenetv2 import... | 1,076 | 28.916667 | 123 | py |
UNIXKD | UNIXKD-master/models/wrn.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Original Author: Wei Yang
"""
__all__ = ['wrn']
class BasicBlock(nn.Module):
def __init__(self, in_planes, out_planes, stride, dropRate=0.0):
super(BasicBlock, self).__init__()
self.bn1 = nn.BatchNorm2d(in_planes)... | 5,519 | 31.280702 | 116 | py |
GraphLIME | GraphLIME-master/setup.py | import setuptools
setuptools.setup(
name="graphlime",
version="1.2.0",
author="williamcchuang",
author_email="hang6318179@gmail.com",
description="A package",
# long_description=long_description,
# long_description_content_type="text/markdown",
url="https://github.com/WilliamCCHuang/Gr... | 570 | 26.190476 | 54 | py |
GraphLIME | GraphLIME-master/graphlime/__init__.py | __version__ = '1.2.0'
__all__ = [
'GraphLIME'
]
import numpy as np
from sklearn.linear_model import LassoLars
import torch
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import k_hop_subgraph
class GraphLIME:
def __init__(self, model, hop=2, rho=0.1, cached=True):
se... | 3,882 | 29.81746 | 89 | py |
GraphLIME | GraphLIME-master/exp/noise_features/other_explainers.py | import copy
import numpy as np
from tqdm import tqdm
from sklearn.linear_model import Ridge
import torch
class LIME:
def __init__(self, model, num_samples, cached=True):
self.model = model
self.num_samples = num_samples
self.cached = cached
self.cached_result = None
self... | 4,242 | 30.902256 | 84 | py |
GraphLIME | GraphLIME-master/exp/noise_features/exp_noise_features.py | from os import sys, path as osp
sys.path.append(osp.dirname(osp.dirname(osp.dirname(__file__))))
import random
import argparse
import warnings
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
import torch
from torch_geometric.nn import GNNExplainer
from models import GAT
from graphlime import... | 7,487 | 33.827907 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.