Dataset Viewer
Auto-converted to Parquet Duplicate
python_code
stringlengths
0
290k
repo_name
stringclasses
30 values
file_path
stringlengths
6
125
from setuptools import find_packages, setup # PEP0440 compatible formatted version, see: # https://www.python.org/dev/peps/pep-0440/ # # release markers: # X.Y # X.Y.Z # For bugfix releases # # pre-release markers: # X.YaN # Alpha release # X.YbN # Beta release # X.YrcN # Release Candidate # X.Y ...
allennlp-master
setup.py
allennlp-master
test_fixtures/__init__.py
from d.d import D
allennlp-master
test_fixtures/plugins/d/__init__.py
import argparse from overrides import overrides from allennlp.commands import Subcommand def do_nothing(_): pass @Subcommand.register("d") class D(Subcommand): @overrides def add_subparser(self, parser: argparse._SubParsersAction) -> argparse.ArgumentParser: subparser = parser.add_parser(self....
allennlp-master
test_fixtures/plugins/d/d.py
import os _MAJOR = "1" _MINOR = "3" # On master and in a nightly release the patch should be one ahead of the last # released build. _PATCH = "0" # This is mainly for nightly builds which have the suffix ".dev$DATE". See # https://semver.org/#is-v123-a-semantic-version for the semantics. _SUFFIX = os.environ.get("ALLE...
allennlp-master
allennlp/version.py
# Make sure that allennlp is running on Python 3.6.1 or later # (to avoid running into this bug: https://bugs.python.org/issue29246) import sys if sys.version_info < (3, 6, 1): raise RuntimeError("AllenNLP requires Python 3.6.1 or later") # We get a lot of these spurious warnings, # see https://github.com/Continu...
allennlp-master
allennlp/__init__.py
#!/usr/bin/env python import logging import os import sys if os.environ.get("ALLENNLP_DEBUG"): LEVEL = logging.DEBUG else: level_name = os.environ.get("ALLENNLP_LOG_LEVEL", "INFO") LEVEL = logging._nameToLevel.get(level_name, logging.INFO) sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.join(__...
allennlp-master
allennlp/__main__.py
allennlp-master
allennlp/tools/__init__.py
import os from allennlp.common.file_utils import CACHE_DIRECTORY from allennlp.common.file_utils import filename_to_url def main(): print(f"Looking for datasets in {CACHE_DIRECTORY}...") if not os.path.exists(CACHE_DIRECTORY): print("Directory does not exist.") print("No cached datasets found...
allennlp-master
allennlp/tools/inspect_cache.py
#! /usr/bin/env python """ Helper script for modifying config.json files that are locked inside model.tar.gz archives. This is useful if you need to rename things or add or remove values, usually because of changes to the library. This script will untar the archive to a temp directory, launch an editor to modify the c...
allennlp-master
allennlp/tools/archive_surgery.py
import argparse import gzip import os import torch from allennlp.common.checks import ConfigurationError from allennlp.data import Token, Vocabulary from allennlp.data.token_indexers import ELMoTokenCharactersIndexer from allennlp.data.vocabulary import DEFAULT_OOV_TOKEN from allennlp.modules.elmo import _ElmoCharact...
allennlp-master
allennlp/tools/create_elmo_embeddings_from_vocab.py
""" Assorted utilities for working with neural networks in AllenNLP. """ import copy import json import logging from collections import defaultdict from typing import Any, Dict, List, Optional, Sequence, Tuple, TypeVar, Union import math import numpy import torch from allennlp.common.checks import ConfigurationError...
allennlp-master
allennlp/nn/util.py
""" An `Activation` is just a function that takes some parameters and returns an element-wise activation function. For the most part we just use [PyTorch activations](https://pytorch.org/docs/master/nn.html#non-linear-activations). Here we provide a thin wrapper to allow registering them and instantiating them `from_pa...
allennlp-master
allennlp/nn/activations.py
from allennlp.nn.activations import Activation from allennlp.nn.initializers import Initializer, InitializerApplicator from allennlp.nn.regularizers import RegularizerApplicator
allennlp-master
allennlp/nn/__init__.py
from inspect import signature from typing import List, Callable, Tuple, Dict, cast, TypeVar import warnings from overrides import overrides import torch from allennlp.common import FromParams, Registrable from allennlp.common.checks import ConfigurationError from allennlp.nn.util import min_value_of_dtype StateType...
allennlp-master
allennlp/nn/beam_search.py
""" An initializer is just a PyTorch function. Here we implement a proxy class that allows us to register them and supply any additional function arguments (for example, the `mean` and `std` of a normal initializer) as named arguments to the constructor. The available initialization functions are * ["normal"](https:/...
allennlp-master
allennlp/nn/initializers.py
from typing import List, Set, Tuple, Dict import numpy from allennlp.common.checks import ConfigurationError def decode_mst( energy: numpy.ndarray, length: int, has_labels: bool = True ) -> Tuple[numpy.ndarray, numpy.ndarray]: """ Note: Counter to typical intuition, this function decodes the _maximum_ ...
allennlp-master
allennlp/nn/chu_liu_edmonds.py
import re from typing import List, Tuple import torch from allennlp.common import FromParams from allennlp.nn.regularizers.regularizer import Regularizer class RegularizerApplicator(FromParams): """ Applies regularizers to the parameters of a Module based on regex matches. """ def __init__(self, re...
allennlp-master
allennlp/nn/regularizers/regularizer_applicator.py
""" This module contains classes representing regularization schemes as well as a class for applying regularization to parameters. """ from allennlp.nn.regularizers.regularizer import Regularizer from allennlp.nn.regularizers.regularizers import L1Regularizer from allennlp.nn.regularizers.regularizers import L2Regular...
allennlp-master
allennlp/nn/regularizers/__init__.py
import torch from allennlp.nn.regularizers.regularizer import Regularizer @Regularizer.register("l1") class L1Regularizer(Regularizer): """ Represents a penalty proportional to the sum of the absolute values of the parameters Registered as a `Regularizer` with name "l1". """ def __init__(self, ...
allennlp-master
allennlp/nn/regularizers/regularizers.py
import torch from allennlp.common import Registrable class Regularizer(Registrable): """ An abstract class representing a regularizer. It must implement call, returning a scalar tensor. """ default_implementation = "l2" def __call__(self, parameter: torch.Tensor) -> torch.Tensor: ra...
allennlp-master
allennlp/nn/regularizers/regularizer.py
from typing import Optional, Iterable, Dict, Any from allennlp.common.checks import ConfigurationError class MetricTracker: """ This class tracks a metric during training for the dual purposes of early stopping and for knowing whether the current value is the best so far. It mimics the PyTorch `state...
allennlp-master
allennlp/training/metric_tracker.py
import os from contextlib import contextmanager from typing import Any, Dict, Iterator, Tuple from allennlp.models import Model from allennlp.training.checkpointer import Checkpointer from allennlp.training.trainer import Trainer @Trainer.register("no_op") class NoOpTrainer(Trainer): """ Registered as a `Tra...
allennlp-master
allennlp/training/no_op_trainer.py
End of preview. Expand in Data Studio

Dataset Card for "all-huggingface-python-code-2"

More Information needed

Downloads last month
8