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 |
|---|---|---|---|---|---|---|
RegularizedBN | RegularizedBN-main/fairseq/data/raw_label_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 torch
from . import FairseqDataset
class RawLabelDataset(FairseqDataset):
def __init__(self, labels):
super().__init__(... | 547 | 20.92 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/resampling_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 logging
import numpy as np
from fairseq.data import BaseWrapperDataset, plasma_utils
logger = logging.getLogger(__name__)
class R... | 4,232 | 29.89781 | 78 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/dictionary.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 os
from collections import Counter
from multiprocessing import Pool
import torch
from fairseq import utils
from fairseq.binarizer impo... | 12,579 | 31.339332 | 87 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/append_token_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 . import BaseWrapperDataset
class AppendTokenDataset(BaseWrapperDataset):
def __init__(self, data... | 1,066 | 23.813953 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/fasta_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 os
import subprocess
import threading
from pathlib import Path
import numpy as np
import torch
def fasta_file_path(prefix_path):
... | 3,387 | 30.37037 | 107 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/mask_tokens_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 numpy as np
import torch
from fairseq.data import data_utils, Dictionary
from . import BaseWrapperDa... | 6,847 | 38.356322 | 87 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/concat_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 bisect
import numpy as np
from torch.utils.data.dataloader import default_collate
from . import FairseqDataset
class ConcatDataset(... | 3,759 | 34.471698 | 86 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/data_utils.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.
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import contextlib
import itertools
impo... | 18,575 | 39.12095 | 151 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/nested_dictionary_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 collections import OrderedDict
import torch
from torch.utils.data.dataloader import default_collate
from . import FairseqDataset
def ... | 3,776 | 31.282051 | 86 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/add_target_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 torch
from . import BaseWrapperDataset
from . import data_utils
class AddTargetDataset(BaseWrapperDataset):
def __init__(self, d... | 2,046 | 35.553571 | 107 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/transform_eos_lang_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.
from . import FairseqDataset
import torch
from typing import Optional
class TransformEosLangPairDataset(FairseqDataset):
"""A :class:`~... | 3,381 | 36.577778 | 110 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/lm_context_window_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.monolingual_dataset import MonolingualDataset
from . import FairseqDataset
class LMConte... | 2,910 | 35.848101 | 90 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/colorize_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 torch
from . import BaseWrapperDataset
class ColorizeDataset(BaseWrapperDataset):
""" Adds 'colors' property to net input that i... | 844 | 32.8 | 113 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/iterators.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 itertools
import logging
import math
import operator
import os
import queue
import time
from threading import Thread
import numpy as n... | 19,798 | 34.292335 | 117 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/backtranslation_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 torch
from fairseq import utils
from . import FairseqDataset
def backtranslate_samples(samples, collate_fn, generate_fn, cuda=True)... | 6,235 | 36.566265 | 93 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/monolingual_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 . import data_utils, FairseqDataset
def collate(samples, pad_idx, eos_idx):
if len(samples) == 0:
... | 7,469 | 36.164179 | 117 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/roll_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 torch
from . import BaseWrapperDataset
class RollDataset(BaseWrapperDataset):
def __init__(self, dataset, shifts):
supe... | 486 | 23.35 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/replace_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 . import BaseWrapperDataset
class ReplaceDataset(BaseWrapperDataset):
"""Replaces tokens found in the dataset by a specified replac... | 1,394 | 36.702703 | 117 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/id_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 torch
from . import FairseqDataset
class IdDataset(FairseqDataset):
def __getitem__(self, index):
return index
def... | 424 | 19.238095 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/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 . import FairseqDataset
from fair... | 16,431 | 29.887218 | 105 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/denoising_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
import math
from . import data_utils, FairseqDataset
def collate(
samples,
pad_idx,
eos_idx,
... | 15,082 | 35.968137 | 118 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/prepend_token_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 . import BaseWrapperDataset
class PrependTokenDataset(BaseWrapperDataset):
def __init__(self, dat... | 1,067 | 23.837209 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/numel_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 . import BaseWrapperDataset
class NumelDataset(BaseWrapperDataset):
def __init__(self, dataset, r... | 787 | 22.878788 | 65 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/noising.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
import numpy as np
from fairseq.data import data_utils
class WordNoising(object):
"""Generate a noisy version of a sentenc... | 12,184 | 37.560127 | 110 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/bucket_pad_length_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.nn.functional as F
from fairseq.data import BaseWrapperDataset
class BucketPadLengthDataset(BaseWrapperData... | 2,261 | 28 | 79 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/concat_sentences_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 torch
from . import FairseqDataset
class ConcatSentencesDataset(FairseqDataset):
def __init__(self, *datasets):
super()... | 1,573 | 26.614035 | 75 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/fairseq_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.utils.data
from fairseq.data import data_utils
class EpochListening:
"""Mixin for receiving updates whe... | 6,723 | 33.482051 | 100 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/transform_eos_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 torch
from . import FairseqDataset
class TransformEosDataset(FairseqDataset):
"""A :class:`~fairseq.data.FairseqDataset` wrapper... | 4,576 | 36.516393 | 88 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/multilingual/sampled_multi_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 typing import List
from enum import Enum
from collections import OrderedDict
from collections import defaultdict
from bisect import bisec... | 16,841 | 41.423174 | 119 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/multilingual/sampled_multi_epoch_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 hashlib
import math
import logging
import time
import numpy as np
import torch
from fairseq import distributed_utils
from fairseq.data... | 11,332 | 42.756757 | 119 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/audio/raw_audio_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 os
import logging
import numpy as np
import sys
import torch
import torch.nn.functional as F
from .. import FairseqDataset
logger =... | 5,341 | 28.351648 | 88 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/encoders/utils.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
from fairseq.data import encoders
def get_whole_word_mask(args, dictionary):
bpe = encoders.build_bpe(args)
if bpe is n... | 907 | 30.310345 | 67 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/legacy/block_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 math
import numpy as np
import torch
from fairseq.data import FairseqDataset
class BlockPairDataset(FairseqDataset):
"""Break a... | 12,878 | 40.146965 | 99 | py |
RegularizedBN | RegularizedBN-main/fairseq/data/legacy/masked_lm_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 math
import numpy as np
import torch
from typing import Dict, List, Tuple
from fairseq.data import FairseqDataset, data_utils
from ... | 12,468 | 37.603715 | 83 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/translation_from_pretrained_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 torch
from fairseq.data import LanguagePairDataset
from fairseq import utils
from .translation import load_langpair_dataset, Translat... | 5,169 | 41.377049 | 108 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/language_modeling.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 logging
import os
import numpy as np
import torch
from fairseq import utils
from fairseq.data import (
AppendTokenDataset,
da... | 11,244 | 37.248299 | 114 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/multilingual_masked_lm.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 logging
import os
import numpy as np
import torch
from fairseq.data import (
data_utils,
Dictionary,
encoders,
Concat... | 12,616 | 38.676101 | 98 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/multilingual_translation.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 collections import OrderedDict
import logging
import os
import contextlib
import torch
from fairseq import metrics, options
from fairse... | 15,948 | 42.936639 | 117 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/translation_lev.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 os
import torch
from fairseq.data import LanguagePairDataset
from fairseq.utils import new_arange
from fairseq.tasks import register... | 7,220 | 40.5 | 108 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/fairseq_task.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 logging
import os
import warnings
import torch
from fairseq import metrics, search, tokenizer, utils
from fairseq.data import data_u... | 18,544 | 37.635417 | 179 | py |
RegularizedBN | RegularizedBN-main/fairseq/tasks/translation_multi_simple_epoch.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 logging
import datetime
import time
import torch
from fairseq.data import (
data_utils,
FairseqDataset,
iterators,
Lan... | 13,953 | 41.284848 | 119 | py |
RegularizedBN | RegularizedBN-main/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# fairseq documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 17 21:45:30 2018.
#
# 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
# au... | 4,235 | 30.849624 | 80 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/train_bn.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.
"""
#****************
#for testing bn
#****************
import ... | 14,061 | 34.420655 | 121 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/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 logging
import math
import os
import sys
import n... | 11,494 | 38.501718 | 192 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/validate.py | #!/usr/bin/env python3 -u
#!/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.
from itertools import chain
import logging
import sys
import torch
from fairseq import c... | 4,297 | 31.315789 | 88 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/eval_lm.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.
"""
Evaluate the perplexity of a trained language model.
"""
import logging
import math
import os
import torch
fr... | 8,744 | 33.160156 | 112 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/interactive.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 raw text with a trained model. Batches data on-the-fly.
"""
from collections import namedtuple
import ... | 10,107 | 34.843972 | 126 | py |
RegularizedBN | RegularizedBN-main/fairseq_cli/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 random
i... | 14,942 | 33.913551 | 121 | py |
torpido | torpido-master/gym/envs/parameter_tuning/train_deep_cnn.py | from __future__ import print_function
import gym
import random
from gym import spaces
import numpy as np
from keras.datasets import cifar10, mnist, cifar100
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.op... | 8,578 | 29.859712 | 110 | py |
torpido | torpido-master/gym/envs/parameter_tuning/convergence.py | from __future__ import print_function
import gym
import random
from gym import spaces
import numpy as np
from keras.datasets import cifar10, mnist, cifar100
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.op... | 9,944 | 31.713816 | 84 | py |
torpido | torpido-master/utils/gcn/layers.py | from gcn.inits import *
import tensorflow as tf
flags = tf.app.flags
FLAGS = flags.FLAGS
# global unique layer ID dictionary for layer name assignment
_LAYER_UIDS = {}
def get_layer_uid(layer_name=''):
"""Helper function, assigns unique layer IDs."""
if layer_name not in _LAYER_UIDS:
_LAYER_UIDS[lay... | 5,886 | 30.148148 | 92 | py |
BDI | BDI-main/utils.py | import os
import re
import requests
import numpy as np
import functools
from jax.experimental import optimizers
import jax
import jax.config
from jax.config import config as jax_config
jax_config.update('jax_enable_x64', True) # for numerical stability, can disable if not an issue
from jax import numpy as jnp
from jax... | 5,913 | 38.691275 | 100 | py |
BDI | BDI-main/BDI.py | import functools
from jax.experimental import optimizers
import jax
import jax.config
from jax.config import config as jax_config
jax_config.update('jax_enable_x64', True) # for numerical stability, can disable if not an issue
from jax import numpy as jnp
from jax import scipy as sp
import numpy as np
import neural_ta... | 3,446 | 39.081395 | 141 | py |
BDI | BDI-main/npy/compute_d.py | import os
import re
import requests
import numpy as np
import functools
from jax.experimental import optimizers
import jax
import jax.config
from jax.config import config as jax_config
jax_config.update('jax_enable_x64', True) # for numerical stability, can disable if not an issue
from jax import numpy as jnp
from jax... | 1,668 | 35.282609 | 196 | py |
BayesFlow | BayesFlow-master/docsrc/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 3,727 | 30.863248 | 86 | py |
BayesFlow | BayesFlow-master/tests/test_benchmarks.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 3,760 | 41.258427 | 119 | py |
BayesFlow | BayesFlow-master/bayesflow/inference_networks.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 22,507 | 43.133333 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/helper_functions.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 10,019 | 39.08 | 119 | py |
BayesFlow | BayesFlow-master/bayesflow/trainers.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 62,525 | 46.189434 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/helper_networks.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 22,112 | 36.416244 | 135 | py |
BayesFlow | BayesFlow-master/bayesflow/coupling_networks.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 32,182 | 43.390345 | 114 | py |
BayesFlow | BayesFlow-master/bayesflow/default_settings.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 6,111 | 29.257426 | 112 | py |
BayesFlow | BayesFlow-master/bayesflow/configuration.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 13,886 | 46.234694 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/wrappers.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 4,193 | 37.477064 | 119 | py |
BayesFlow | BayesFlow-master/bayesflow/amortizers.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 57,826 | 46.052075 | 128 | py |
BayesFlow | BayesFlow-master/bayesflow/attention.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 12,081 | 43.914498 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/summary_networks.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 26,357 | 42.93 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/helper_classes.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 31,839 | 37.223289 | 120 | py |
BayesFlow | BayesFlow-master/bayesflow/experimental/rectifiers.py | # Copyright (c) 2022 The BayesFlow Developers
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publ... | 19,610 | 45.035211 | 128 | py |
FinRL_Market_Simulator | FinRL_Market_Simulator-master/policy_twap.py | """
TWAP strategy
"""
import torch
import torch.nn as nn
import torch.optim as opt
from torch import Tensor
from torch.autograd import Variable
import torch.nn.functional as F
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from constants import CODE_LIST, JUNE_DATE_LIST, VALIDATION_DATE_LIST... | 9,303 | 35.486275 | 131 | py |
FinRL_Market_Simulator | FinRL_Market_Simulator-master/policy_tuned_ppo.py | """
Tuned PPO algorithm for optimized trade execution
"""
from env_v2 import make_env
from storage import RolloutStorage
from constants import CODE_LIST, JUNE_DATE_LIST, VALIDATION_DATE_LIST, VALIDATION_CODE_LIST
from sklearn.preprocessing import StandardScaler
from pathos.multiprocessing import ProcessingPool as Poo... | 28,315 | 34.572864 | 153 | py |
FinRL_Market_Simulator | FinRL_Market_Simulator-master/policy_tuned_dqn.py | """
Tuned DQN algorithm for optimized trade execution
"""
import torch
import torch.nn as nn
import torch.optim as opt
from torch import Tensor
from torch.autograd import Variable
import torch.nn.functional as F
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from constants import CODE_LIST, ... | 24,410 | 39.82107 | 135 | py |
FinRL_Market_Simulator | FinRL_Market_Simulator-master/OrderExecution/order_execution_env.py | import os
import torch
from random import shuffle
from functorch import vmap
from shares_data_process import get_share_dicts_by_day
"""
Readme 写于 2022-11-08 17:28:39
## OrderExecutionEnv 订单执行仿真环境
### 什么是订单执行任务?
举例:我持有1000股茅台,想要在一个月内,拿到股票市场上卖掉,换取尽可能多的现金。
设置较高的价格卖出,能多换取现金,但自己持有的股票就无法在规定时限内卖出。
所以交易员会设计“订单执行策略”,根据市场行情,将... | 33,366 | 41.559949 | 117 | py |
FinRL_Market_Simulator | FinRL_Market_Simulator-master/OrderExecution/plot.py | import os
import torch
from OrderExecutionEnv import OrderExecutionVecEnvForEval
"""run"""
def check__ask_price_volume():
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" # OMP: Error #15: Initializing libiomp5md.dll
import matplotlib.pyplot as plt
import numpy as np
num_envs = 2
env = OrderExecuti... | 11,653 | 39.748252 | 111 | py |
MRMGA4VAD | MRMGA4VAD-main/calc_img_inputs.py | import torch
import numpy as np
import cv2
from collections import OrderedDict
import os
import glob
# import scipy.io as sio
from torch.utils.data import Dataset, DataLoader
from vad_datasets import ped_dataset, avenue_dataset, shanghaiTech_dataset
from FlowNet2_src import FlowNet2, flow_to_image
from torch.autograd i... | 4,952 | 44.027273 | 138 | py |
MRMGA4VAD | MRMGA4VAD-main/test.py | from xml.sax.xmlreader import InputSource
import torch
import numpy as np
import os
from torch.utils.data import DataLoader
from vad_datasets import unified_dataset_interface
from vad_datasets import bbox_collate, img_tensor2numpy, img_batch_tensor2numpy, frame_size, cube_to_train_dataset
from state_model import Con... | 39,523 | 56.868228 | 321 | py |
MRMGA4VAD | MRMGA4VAD-main/state_model.py | import torch
import torch.nn as nn
import numpy as np
from module import *
# LSTM
class ConvLSTMCell(nn.Module):
def __init__(self, input_dim, hidden_dim, kernel_size, bias):
"""
Initialize ConvLSTM cell.
Parameters
----------
input_dim: int
Number of channels o... | 21,874 | 36.521441 | 139 | py |
MRMGA4VAD | MRMGA4VAD-main/vad_datasets.py | import torch
import numpy as np
import cv2
from collections import OrderedDict
import os
import glob
import scipy.io as sio
import torch
from torch.utils.data import Dataset, DataLoader
import torchvision.transforms as transforms
transform = transforms.Compose([
transforms.ToTensor(),
])
# frame_size: the ... | 39,197 | 43.291525 | 191 | py |
MRMGA4VAD | MRMGA4VAD-main/module.py |
import torch
import torch.nn as nn
import copy
from module_utils import *
import torch.nn.functional as F
from matplotlib import pyplot as plt
####################################################################################
######################### definition for encoder #################################
####... | 5,573 | 43.951613 | 121 | py |
MRMGA4VAD | MRMGA4VAD-main/resnet_pytorch.py | '''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 math
__all__ = ['resnet']
def conv3x3(in_planes, out_planes, stride=1):
"3x3 convolution with padding"... | 5,088 | 29.842424 | 116 | py |
MRMGA4VAD | MRMGA4VAD-main/module_utils.py | import torch
import torch.nn as nn
from torch.nn import init
import math
import copy
import numpy as np
from skimage import measure
class QNet(nn.Module):
def __init__(self, depth=32):
super(QNet, self).__init__()
self.conv0 = nn.Sequential(
nn.Conv2d(in_channels=depth, out_channels=de... | 4,119 | 30.212121 | 108 | py |
MRMGA4VAD | MRMGA4VAD-main/train.py | import numpy as np
import os
from torch.utils.data import DataLoader
from vad_datasets import unified_dataset_interface, cube_to_train_dataset
from vad_datasets import bbox_collate, img_tensor2numpy, img_batch_tensor2numpy, frame_size
from helper.misc import AverageMeter
import torch
from state_model import ConvTrans... | 34,551 | 57.86201 | 197 | py |
MRMGA4VAD | MRMGA4VAD-main/fore_det/inference.py | import warnings
import matplotlib.pyplot as plt
import mmcv
import numpy as np
import pycocotools.mask as maskUtils
import torch
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint
from mmdet.core import get_classes
from mmdet.datasets.pipelines import Compose
from mmdet.models import bui... | 7,224 | 33.241706 | 79 | py |
MRMGA4VAD | MRMGA4VAD-main/fore_det/obj_det_with_motion.py | import mmcv
from mmcv.image import imread, imwrite
import cv2
from fore_det.inference import inference_detector, init_detector, show_result
import numpy as np
from sklearn import preprocessing
import os
from torch.utils.data import Dataset, DataLoader
from vad_datasets import ped_dataset, avenue_dataset, shanghaiTech_d... | 6,865 | 29.927928 | 133 | py |
MRMGA4VAD | MRMGA4VAD-main/obj_det_config/cascade_rcnn_r101_fpn_1x.py | # model settings
model = dict(
type='CascadeRCNN',
num_stages=3,
pretrained='torchvision://resnet101',
backbone=dict(
type='ResNet',
depth=101,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
style='pytorch'),
neck=dict(
type='FPN',
... | 7,380 | 30.408511 | 78 | py |
MRMGA4VAD | MRMGA4VAD-main/helper/misc.py | '''Some helper functions for PyTorch, including:
- get_mean_and_std: calculate the mean and std value of dataset.
- msr_init: net parameter initialization.
- progress_bar: progress bar mimic xlua.progress.
'''
import errno
import os
import sys
import time
import math
import torch
import torch.nn as nn
impor... | 2,218 | 28.197368 | 110 | py |
CANTM | CANTM-main/updateTopics_covid.py | import sys
from GateMIcateLib import ModelUltiUpdateCAtopic as ModelUlti
from GateMIcateLib import BatchIterBert, DictionaryProcess
from GateMIcateLib.batchPostProcessors import bowBertBatchProcessor as batchPostProcessor
from GateMIcateLib import ScholarPostProcessor as ReaderPostProcessor
from GateMIcateLib.readers i... | 3,093 | 37.675 | 175 | py |
CANTM | CANTM-main/getPerpare.py | import os
import torch
from transformers import *
import nltk
from pathlib import Path
nltk.download('stopwords')
nltk.download('punkt')
model = BertModel.from_pretrained('bert-base-uncased')
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
script_path = os.path.abspath(__file__)
print(script_path)
par... | 753 | 25 | 62 | py |
CANTM | CANTM-main/updateTopics.py | import sys
from GateMIcateLib import ModelUltiUpdateCAtopic as ModelUlti
from GateMIcateLib import BatchIterBert, DictionaryProcess
from GateMIcateLib.batchPostProcessors import bowBertBatchProcessor as batchPostProcessor
from GateMIcateLib import ScholarPostProcessor as ReaderPostProcessor
from GateMIcateLib.readers i... | 2,718 | 38.405797 | 175 | py |
CANTM | CANTM-main/GateMIcateLib/modelUltiClassTopic.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import numpy as np
import copy
import os
from pathlib import Path
import pickle
import datetime
from .modelUlti import modelUlti
class ModelUltiClass(modelUlti):
def __init__(self, net=None, gpu=False, load_path=None):
... | 11,148 | 37.711806 | 270 | py |
CANTM | CANTM-main/GateMIcateLib/modelUltiUpdateCATopic.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import numpy as np
import copy
import os
from pathlib import Path
import pickle
from .modelUltiClassTopic import ModelUltiClass
class ModelUltiUpdateCAtopic(ModelUltiClass):
def __init__(self, net=None, gpu=False, load_p... | 2,399 | 31 | 125 | py |
CANTM | CANTM-main/GateMIcateLib/batchPostProcessors.py | import torch
def xonlyBatchProcessor(x, y):
ss = [s[1] for s in x]
return ss[0]
def bowBertBatchProcessor(raw_x, y):
x = [s[0] for s in raw_x]
idded_words = [s[1] for s in raw_x]
y_class = y
return torch.tensor(x), torch.tensor(idded_words), torch.tensor(y_class)
def xyOnlyBertBatchProcessor... | 508 | 21.130435 | 76 | py |
CANTM | CANTM-main/GateMIcateLib/modelUltiVAEtm_noatt.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import numpy as np
import copy
import os
from pathlib import Path
from .modelUlti import modelUlti
class ModelUltiVAEtmNOatt(modelUlti):
def __init__(self, net=None, gpu=False):
super().__init__(net=net, gpu=gpu)... | 6,838 | 38.304598 | 138 | py |
CANTM | CANTM-main/GateMIcateLib/modelUlti.py | import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import numpy as np
import os
from pathlib import Path
class modelUlti:
def __init__(self, net=None, gpu=False):
if net:
self.net = net
self.gpu = gpu
if self.gpu and net:
s... | 8,968 | 35.02008 | 126 | py |
CANTM | CANTM-main/GateMIcateLib/EvaluationManager.py | import sys
import nltk
import math
from GateMIcateLib import BatchIterBert, DictionaryProcess
#from GateMIcateLib import WVPostProcessor as ReaderPostProcessor
from configobj import ConfigObj
import torch
import argparse
import copy
from sklearn.model_selection import KFold
import random
import os
from pathlib import P... | 20,370 | 42.342553 | 208 | py |
CANTM | CANTM-main/GateMIcateLib/models/CLSAW_TopicModel_simple_loss.py | import torch
from torch import nn
from torch.nn import init
from torch.nn import functional as F
import math
from .miscLayer import BERT_Embedding, WVHidden, WVClassifier, Identity, Topics, kld, CLSAW_TopicModel_Base
class CLSAW_TopicModelSL(CLSAW_TopicModel_Base):
def __init__(self, config, vocab_dim=None):
... | 6,776 | 35.435484 | 150 | py |
CANTM | CANTM-main/GateMIcateLib/models/CLSAW_TopicModel.py | import torch
from torch import nn
from torch.nn import init
from torch.nn import functional as F
import math
from .miscLayer import BERT_Embedding, WVHidden, WVClassifier, Identity, Topics, kld, CLSAW_TopicModel_Base
class CLSAW_TopicModel(CLSAW_TopicModel_Base):
def __init__(self, config, vocab_dim=None):
... | 7,541 | 35.434783 | 150 | py |
CANTM | CANTM-main/GateMIcateLib/models/CLSAW_TopicModelBertEnrich.py | import torch
from torch import nn
from torch.nn import init
from torch.nn import functional as F
import math
from .miscLayer import BERT_Embedding, WVHidden, WVClassifier, Identity, Topics, kld, CLSAW_TopicModel_Base
class CLSAW_TopicModel_BERTEN(CLSAW_TopicModel_Base):
def __init__(self, config, vocab_dim=None):... | 7,008 | 34.760204 | 150 | py |
CANTM | CANTM-main/GateMIcateLib/models/miscLayer.py | from transformers import BertModel
import math
import os
import torch.nn.functional as F
import torch
import torch.nn as nn
class SingleHeadAttention(nn.Module):
def __init__(self, d_model, d_output, dropout = 0.1):
super().__init__()
self.q = nn.Parameter(torch.randn([d_output, 1]).float())
... | 9,182 | 29.407285 | 103 | py |
CANTM | CANTM-main/GateMIcateLib/models/CLSAW_TopicModel_linear.py | import torch
from torch import nn
from torch.nn import init
from torch.nn import functional as F
import math
from .miscLayer import BERT_Embedding, WVHidden, WVClassifier, Identity, Topics, kld, CLSAW_TopicModel_Base
class CLSAW_TopicModel(CLSAW_TopicModel_Base):
def __init__(self, config, vocab_dim=None):
... | 6,843 | 35.795699 | 150 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.