id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
28,833 | import argparse
import time
from functools import partial
from typing import Callable
from compressors import *
from data import *
from experiments import *
from pathos.multiprocessing import ProcessingPool as Pool
from torchtext.datasets import (
AG_NEWS,
IMDB,
AmazonReviewPolarity,
DBpedia,
SogouN... | null |
28,834 | import argparse
import time
from functools import partial
from typing import Callable
from compressors import *
from data import *
from experiments import *
from pathos.multiprocessing import ProcessingPool as Pool
from torchtext.datasets import (
AG_NEWS,
IMDB,
AmazonReviewPolarity,
DBpedia,
SogouN... | null |
28,835 | import argparse
import time
from functools import partial
from typing import Callable
from compressors import *
from data import *
from experiments import *
from pathos.multiprocessing import ProcessingPool as Pool
from torchtext.datasets import (
AG_NEWS,
IMDB,
AmazonReviewPolarity,
DBpedia,
SogouN... | null |
28,836 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
def _load_csv_filepath(csv_filepath: str) -> list... | Reads a csv file and returns a dictionary containing title+description: label pairs. Arguments: filename (str): Filepath to a csv file containing label, title, description. Returns: dict: {title. description: label} pairings. |
28,837 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
def _load_csv_filepath(csv_filepath: str) -> list... | Reads the first item from the `filename` csv filepath in each row. Arguments: filename (str): Filepath to a csv file containing label, title, description. Returns: list: Labels from the `fn` filepath. |
28,838 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Opens a compressed file and returns the contents and delimits the contents on new lines. Arguments: filename (str): Filepath to a compressed file. Returns: list: Compressed file contents line separated. |
28,839 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Extracts the text and labels lists from a pytorch `dataset` on `indices`. Arguments: dataset (list): List of lists containing text and labels. indices (list): List of list indices to extract text and labels on from `dataset`. Returns: (list, list): Text and Label pairs from `dataset` on `indices`. |
28,840 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the 20NewsGroups dataset from `torchtext`. Returns: tuple: Tuple of Lists, with training data at index 0 and test at index 1. |
28,841 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the Ohsumed dataset from `local_directory`. Assumes the existence of subdirectories `training` and `test`. :ref: https://paperswithcode.com/dataset/ohsumed Arguments: local_directory (str): Local path to directory containing the Ohsumed `training` and `test` subdirectories. Returns: tuple: Pair of training and te... |
28,842 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the Ohsumed dataset and performs a train-test-split. Arguments: data_directory (str): Directory containing the ohsumed dataset. split (float): % train size split. Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,843 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the R8 dataset. Arguments: data_directory (str): Directory containing the R8 dataset. delimiter (str): File delimiter to parse on. Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,844 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the TREC dataset from a directory. Arguments: data_directory (str): Directory containing the TREC dataset. Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,845 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the KINNEWS and KIRNEWS datasets. :ref: https://huggingface.co/datasets/kinnews_kirnews Arguments: dataset_name (str): Name of the dataset to be loaded. data_split (str): The data split to be loaded. Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,846 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the Swahili dataset Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,847 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads the Dengue Filipino dataset from local directory :ref: https://github.com/jcblaisecruz02/Filipino-Text-Benchmarks#datasets Arguments: data_directory (str): Directory containing Dengue Filipino dataset Returns: tuple: Tuple of lists containing the training and testing datasets respectively. |
28,848 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Loads items from `dataset` based on the indices listed in `indices` and optionally flattens them. Arguments: dataset (list): List of images. indices (list): indices of `dataset` to be returned. flatten (bool): [Optional] Optionally flatten the image. Returns: tuple: (np.ndarray, np.ndarray) of images and labels respect... |
28,849 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Given an image dataset and a list of indices, this function returns the labels from the dataset. Arguments: dataset (list): List of images. indices (list): indices of `dataset` to be returned. Returns: list: Image labels. |
28,850 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
def _load_csv_filepath(csv_filepath: str) -> list... | Grabs a random sample of size `n_samples` for each label from the csv file at `filename`. Arguments: filename (str): Relative path to the file you want to load. n_samples (int): Number of samples to load and return for each label. idx_only (bool): True if you only want to return the indices of the rows to load. Returns... |
28,851 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Grabs a random sample of size `n_samples` for each label from the dataset `dataset`. Arguments: dataset (Iterable): Labeled data, in ``label, text`` pairs. n_samples (int): Number of samples to load and return for each label. output_filename (str): [Optional] Where to save the recorded indices. index_only (bool): True ... |
28,852 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
The provided code snippet includes necessary dep... | Grabs a random sample of size `n_samples` for each label from the dataset `dataset`. Arguments: dataset (list): Relative path to the file you want to load. n_samples (int): Number of samples to load and return for each label. flatten (bool): True if you want to flatten the images. Returns: tuple: Tuple of samples, labe... |
28,853 | import csv
import os
import random
from collections import defaultdict
from collections.abc import Iterable
from typing import Optional, Sequence, Union
import numpy as np
import unidecode
from datasets import load_dataset
from sklearn.datasets import fetch_20newsgroups
def load_custom_dataset(directory: str, delimite... | null |
28,854 | import numpy as np
from sklearn.metrics import classification_report
from torchtext.datasets import IMDB
from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.knn_classifier import KnnClassifier
The provided code snippet includes necessary de... | Pulls the IMDB sentiment analysis dataset and returns two tuples the first being the training data and the second being the test data. Each tuple contains the text and label respectively as numpy arrays. |
28,855 | import numpy as np
from sklearn.metrics import classification_report
from torchtext.datasets import IMDB
from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.knn_classifier import KnnClassifier
class BaseCompressor:
"""
Default compr... | Fits a Knn-GZip compressor on the train data and returns it. Arguments: train_text (np.ndarray): Training dataset as a numpy array. train_labels (np.ndarray): Training labels as a numpy array. Returns: KnnClassifier: Trained Knn-Compressor model ready to make predictions. |
28,856 | import numpy as np
from sklearn.metrics import classification_report
from torchtext.datasets import AG_NEWS
from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.knn_classifier import KnnClassifier
The provided code snippet includes necessary... | Pulls the AG_NEWS dataset and returns two tuples the first being the training data and the second being the test data. Each tuple contains the text and label respectively as numpy arrays. |
28,857 | import numpy as np
from sklearn.metrics import classification_report
from torchtext.datasets import AG_NEWS
from npc_gzip.compressors.base import BaseCompressor
from npc_gzip.compressors.gzip_compressor import GZipCompressor
from npc_gzip.knn_classifier import KnnClassifier
class BaseCompressor:
"""
Default co... | Fits a Knn-GZip compressor on the train data and returns it. Arguments: train_text (np.ndarray): Training dataset as a numpy array. train_labels (np.ndarray): Training labels as a numpy array. Returns: KnnClassifier: Trained Knn-Compressor model ready to make predictions. |
28,858 | import random
import string
def generate_sentence(number_of_words: int = 10) -> str:
"""
Generates a sentence of random
numbers and letters, with
`number_of_words` words in the
sentence such that len(out.split()) \
== `number_of_words`.
Arguments:
number_of_words (int): The number of... | Loops over `range(number_of_sentences)` that utilizes `generate_sentence()` to generate a dataset of randomly sized sentences. Arguments: number_of_sentences (int): The number of sentences you want in your dataset. Returns: list: List of sentences (str). |
28,859 | import itertools
The provided code snippet includes necessary dependencies for implementing the `concatenate_with_space` function. Write a Python function `def concatenate_with_space(stringa: str, stringb: str) -> str` to solve the following problem:
Combines `stringa` and `stringb` with a space. Arguments: stringa (s... | Combines `stringa` and `stringb` with a space. Arguments: stringa (str): First item. stringb (str): Second item. Returns: str: `{stringa} {stringb}` |
28,860 | import itertools
The provided code snippet includes necessary dependencies for implementing the `aggregate_strings` function. Write a Python function `def aggregate_strings(stringa: str, stringb: str, by_character: bool = False) -> str` to solve the following problem:
Aggregates strings. (replaces agg_by_jag_char, agg... | Aggregates strings. (replaces agg_by_jag_char, agg_by_jag_word) Arguments: stringa (str): First item. stringb (str): Second item. by_character (bool): True if you want to join the combined string by character, Else combines by word Returns: str: combination of stringa and stringb |
28,861 | import os
import sys
from setuptools import find_packages
from numpy.distutils.core import setup
def configuration(parent_package="", top_path=None):
if os.path.exists("MANIFEST"):
os.remove("MANIFEST")
from numpy.distutils.misc_util import Configuration
config = Configuration(None, parent_packa... | null |
28,862 | import numpy as np
from datetime import datetime
from . import _cutils as _LIB
The provided code snippet includes necessary dependencies for implementing the `merge_proba` function. Write a Python function `def merge_proba(probas, n_outputs)` to solve the following problem:
Merge an array that stores multiple class di... | Merge an array that stores multiple class distributions from all estimators in a cascade layer into a final class distribution. |
28,863 | import numpy as np
from datetime import datetime
from . import _cutils as _LIB
The provided code snippet includes necessary dependencies for implementing the `init_array` function. Write a Python function `def init_array(X, n_aug_features)` to solve the following problem:
Initialize a array that stores the intermediat... | Initialize a array that stores the intermediate data used for training or evaluating the model. |
28,864 | import numpy as np
from datetime import datetime
from . import _cutils as _LIB
The provided code snippet includes necessary dependencies for implementing the `merge_array` function. Write a Python function `def merge_array(X_middle, X_aug, n_features)` to solve the following problem:
Update the array created by `init_... | Update the array created by `init_array` with additional checks on the layout. |
28,865 | import os
import numpy
from distutils.version import LooseVersion
from numpy.distutils.misc_util import Configuration
CYTHON_MIN_VERSION = "0.24"
def configuration(parent_package="", top_path=None):
libraries = []
if os.name == "posix":
libraries.append("m")
config = Configuration("deepforest", p... | null |
28,866 | import numbers
from warnings import warn
import threading
from typing import List
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import issparse
from joblib import Parallel, delayed
from joblib import effective_n_jobs
from sklearn.base import clone
from sklearn.base import BaseEstimator
fr... | Get the number of samples in a bootstrap sample. Parameters ---------- n_samples : int Number of samples in the dataset. max_samples : int or float The maximum number of samples to draw from the total available: - if float, this indicates a fraction of the total and should be the interval `(0, 1)`; - if int, this indic... |
28,867 | import numbers
from warnings import warn
import threading
from typing import List
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import issparse
from joblib import Parallel, delayed
from joblib import effective_n_jobs
from sklearn.base import clone
from sklearn.base import BaseEstimator
fr... | Private function used to fit a single tree in parallel. |
28,868 | import numbers
from warnings import warn
import threading
from typing import List
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import issparse
from joblib import Parallel, delayed
from joblib import effective_n_jobs
from sklearn.base import clone
from sklearn.base import BaseEstimator
fr... | Set fixed random_state parameters for an estimator. Finds all parameters ending ``random_state`` and sets them to integers derived from ``random_state``. Parameters ---------- estimator : estimator supporting get/set_params Estimator with potential randomness managed by random_state parameters. random_state : int or Ra... |
28,869 | import numbers
from warnings import warn
import threading
from typing import List
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import issparse
from joblib import Parallel, delayed
from joblib import effective_n_jobs
from sklearn.base import clone
from sklearn.base import BaseEstimator
fr... | Private function used to partition estimators between jobs. |
28,870 | import numbers
from warnings import warn
import threading
from typing import List
from abc import ABCMeta, abstractmethod
import numpy as np
from scipy.sparse import issparse
from joblib import Parallel, delayed
from joblib import effective_n_jobs
from sklearn.base import clone
from sklearn.base import BaseEstimator
fr... | This is a utility function for joblib's Parallel. |
28,871 | import os
import numpy
from numpy.distutils.misc_util import Configuration
def configuration(parent_package="", top_path=None):
config = Configuration("tree", parent_package, top_path)
libraries = []
if os.name == "posix":
libraries.append("m")
config.add_extension(
"_tree",
sou... | null |
28,872 | import numbers
import time
from abc import ABCMeta, abstractmethod
import numpy as np
from sklearn.base import (
BaseEstimator,
ClassifierMixin,
RegressorMixin,
is_classifier,
)
from sklearn.preprocessing import LabelEncoder
from sklearn.utils import check_array, check_X_y
from sklearn.utils.multiclass ... | Build the predictor concatenated to the deep forest. |
28,873 | import numbers
import time
from abc import ABCMeta, abstractmethod
import numpy as np
from sklearn.base import (
BaseEstimator,
ClassifierMixin,
RegressorMixin,
is_classifier,
)
from sklearn.preprocessing import LabelEncoder
from sklearn.utils import check_array, check_X_y
from sklearn.utils.multiclass ... | Build the predictor concatenated to the deep forest. |
28,874 | import numbers
import time
from abc import ABCMeta, abstractmethod
import numpy as np
from sklearn.base import (
BaseEstimator,
ClassifierMixin,
RegressorMixin,
is_classifier,
)
from sklearn.preprocessing import LabelEncoder
from sklearn.utils import check_array, check_X_y
from sklearn.utils.multiclass ... | Decorator on obtaining documentation for deep forest models. Parameters ---------- header: string Introduction to the decorated class or method. item : string Type of the docstring item. |
28,875 | import numpy as np
from .forest import (
RandomForestClassifier,
ExtraTreesClassifier,
RandomForestRegressor,
ExtraTreesRegressor,
)
from sklearn.ensemble import (
RandomForestClassifier as sklearn_RandomForestClassifier,
ExtraTreesClassifier as sklearn_ExtraTreesClassifier,
RandomForestRegr... | null |
28,876 | import numpy as np
from .forest import (
RandomForestClassifier,
ExtraTreesClassifier,
RandomForestRegressor,
ExtraTreesRegressor,
)
from sklearn.ensemble import (
RandomForestClassifier as sklearn_RandomForestClassifier,
ExtraTreesClassifier as sklearn_ExtraTreesClassifier,
RandomForestRegr... | null |
28,877 | import numpy as np
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils import check_random_state, check_array
from . import _cutils as _LIB
def _find_binning_thresholds_per_feature(
col_data, n_bins, bin_type="percentile"
):
"""
Private function used to find midpoints for samples alo... | null |
28,878 | import numpy as np
from sklearn.base import is_classifier
from sklearn.metrics import accuracy_score, mean_squared_error
from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
from . import _utils
from ._estimator import Estimator
from .utils.kfoldwrapper import KFoldWrapper
The provided code snippet ... | Private function used to fit a single estimator. |
28,879 | import os
import shutil
import warnings
import tempfile
from joblib import load, dump
The provided code snippet includes necessary dependencies for implementing the `model_mkdir` function. Write a Python function `def model_mkdir(dirname)` to solve the following problem:
Make the directory for saving the model.
Here ... | Make the directory for saving the model. |
28,880 | import os
import shutil
import warnings
import tempfile
from joblib import load, dump
The provided code snippet includes necessary dependencies for implementing the `model_saveobj` function. Write a Python function `def model_saveobj(dirname, obj_type, obj, partial_mode=False)` to solve the following problem:
Save obj... | Save objects of the deep forest according to the specified type. |
28,881 | import os
import shutil
import warnings
import tempfile
from joblib import load, dump
class ClassificationCascadeLayer(BaseCascadeLayer, ClassifierMixin):
"""Implementation of the cascade forest layer for classification."""
def __init__(
self,
layer_idx,
n_outputs,
criterion,
... | Load objects of the deep forest from the given directory. |
28,882 | import datetime
from importlib import util as import_util
import os
import sys
from setuptools import find_packages
from setuptools import setup
import setuptools.command.build_py
import setuptools.command.develop
core_requirements = [
'absl-py',
'dm-env',
'dm-tree',
'numpy',
'pillow',
'typing-e... | Generates requirements.txt file with the Acme's dependencies. It is used by Launchpad GCP runtime to generate Acme requirements to be installed inside the docker image. Acme itself is not installed from pypi, but instead sources are copied over to reflect any local changes made to the codebase. Args: path: path to the ... |
28,883 | from typing import Callable, Dict
from absl import flags
from acme import specs
from acme.agents.jax.multiagent import decentralized
from absl import app
import helpers
from acme.jax import experiments
from acme.jax import types as jax_types
from acme.multiagent import types as ma_types
from acme.utils import lp_utils
... | Returns a config for multigrid experiments. |
28,884 | import functools
from typing import Any, Dict, NamedTuple, Sequence
from acme import specs
from acme.agents.jax import ppo
from acme.agents.jax.multiagent.decentralized import factories
from acme.jax import networks as networks_lib
from acme.jax import utils as acme_jax_utils
from acme.multiagent import types as ma_typ... | Returns DQN networks used by the agent in the multigrid environment. |
28,885 | from absl import app
from absl import flags
import acme
from acme import specs
from acme import wrappers
from acme.agents.tf import impala
from acme.tf import networks
import bsuite
import sonnet as snt
def make_network(action_spec: specs.DiscreteArray) -> snt.RNNCore:
return snt.DeepRNN([
snt.Flatten(),
... | null |
28,886 | from typing import Tuple
from absl import app
from absl import flags
import acme
from acme import specs
from acme import wrappers
from acme.agents.tf import mcts
from acme.agents.tf.mcts import models
from acme.agents.tf.mcts.models import mlp
from acme.agents.tf.mcts.models import simulator
from acme.tf import network... | Create environment and corresponding model (learned or simulator). |
28,887 | from typing import Tuple
from absl import app
from absl import flags
import acme
from acme import specs
from acme import wrappers
from acme.agents.tf import mcts
from acme.agents.tf.mcts import models
from acme.agents.tf.mcts.models import mlp
from acme.agents.tf.mcts.models import simulator
from acme.tf import network... | null |
28,888 | import functools
from typing import Dict, Sequence
from absl import app
from absl import flags
from acme import specs
from acme.agents.tf import dmpo
from acme.datasets import image_augmentation
import helpers
from acme.tf import networks
import launchpad as lp
import numpy as np
import sonnet as snt
import tensorflow ... | Creates networks used by the agent. |
28,889 | import functools
from typing import Dict, Sequence
from absl import app
from absl import flags
from acme import specs
from acme import types
from acme.agents.tf import ddpg
import helpers
from acme.tf import networks
from acme.tf import utils as tf2_utils
import launchpad as lp
import numpy as np
import sonnet as snt
... | Creates networks used by the agent. |
28,890 | import functools
from typing import Dict, Sequence
from absl import app
from absl import flags
from acme import specs
from acme import types
from acme.agents.tf import mpo
import helpers
from acme.tf import networks
from acme.tf import utils as tf2_utils
import launchpad as lp
import numpy as np
import sonnet as snt
T... | Creates networks used by the agent. |
28,891 | from typing import Optional
from acme import wrappers
import dm_env
The provided code snippet includes necessary dependencies for implementing the `make_environment` function. Write a Python function `def make_environment( evaluation: bool = False, domain_name: str = 'cartpole', task_name: str = 'balance',... | Implements a control suite environment factory. |
28,892 | import functools
from typing import Dict, Sequence
from absl import app
from absl import flags
from acme import specs
from acme import types
from acme.agents.tf import dmpo
import helpers
from acme.tf import networks
import launchpad as lp
import numpy as np
import sonnet as snt
The provided code snippet includes nece... | Creates networks used by the agent. |
28,893 | import functools
from typing import Callable, Dict, Sequence, Union
from absl import app
from absl import flags
from acme import specs
from acme.agents.tf import d4pg
import helpers
from acme.tf import networks
from acme.tf import utils as tf2_utils
import launchpad as lp
import numpy as np
import sonnet as snt
import ... | Creates networks used by the agent. |
28,894 | import functools
from typing import Dict, Sequence
from absl import app
from absl import flags
from acme import specs
from acme import types
from acme.agents.tf import dmpo
import helpers
from acme.tf import networks
from acme.tf import utils as tf2_utils
import launchpad as lp
import numpy as np
import sonnet as snt
... | Creates networks used by the agent. |
28,895 | import functools
import operator
from absl import app
from absl import flags
import acme
from acme import specs
from acme import types
from acme.agents.tf import actors
from acme.agents.tf.bc import learning
from acme.agents.tf.dqfd import bsuite_demonstrations
from acme.tf import utils as tf2_utils
from acme.utils imp... | null |
28,896 | import functools
import operator
from absl import app
from absl import flags
import acme
from acme import specs
from acme import types
from acme.agents.tf import actors
from acme.agents.tf.bc import learning
from acme.agents.tf.dqfd import bsuite_demonstrations
from acme.tf import utils as tf2_utils
from acme.utils imp... | Produce Reverb-like N-step transition from a full episode. Observations, actions, rewards and discounts have the same length. This function will ignore the first reward and discount and the last action. Args: observations: [L, ...] Tensor. actions: [L, ...] Tensor. rewards: [L] Tensor. discounts: [L] Tensor. n_step: nu... |
28,897 | import functools
import operator
from typing import Callable
from acme import core
from acme import environment_loop
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import bc
from acme.agents.tf.dqfd import bs... | Creates networks used by the agent. |
28,898 | import functools
import operator
from typing import Callable
from acme import core
from acme import environment_loop
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import bc
from acme.agents.tf.dqfd import bs... | null |
28,899 | import functools
import operator
from typing import Callable
from acme import core
from acme import environment_loop
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import bc
from acme.agents.tf.dqfd import bs... | Prepare the dataset of demonstrations. |
28,900 | import functools
import operator
from typing import Callable
from acme import core
from acme import environment_loop
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import bc
from acme.agents.tf.dqfd import bs... | Makes an evaluator that runs the agent on the environment. Args: environment_factory: Function that creates a dm_env. evaluator_network: Network to be use by the actor. Returns: actor_evaluator: Function that returns a Worker that will be executed by launchpad. |
28,901 | from absl import app
from absl import flags
import acme
from acme import specs
from acme.agents.tf import actors
from acme.agents.tf import bcq
from acme.tf import networks
from acme.tf import utils as tf2_utils
from acme.utils import counting
from acme.utils import loggers
import sonnet as snt
import tensorflow as tf
... | null |
28,902 | from absl import app
from absl import flags
import acme
from acme import specs
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import td3
from acme.datasets import tfds
from acme.examples.offline import helpers as gym_helpers
from acme.jax import variable... | null |
28,903 | from absl import app
from absl import flags
import acme
from acme import specs
from acme import wrappers
from acme.agents.tf import dqfd
from acme.agents.tf.dqfd import bsuite_demonstrations
import bsuite
import sonnet as snt
def make_network(action_spec: specs.DiscreteArray) -> snt.Module:
return snt.Sequential([
... | null |
28,904 | from absl import app
from absl import flags
import acme
from acme import specs
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import actors
from acme.agents.jax import crr
from acme.datasets import tfds
from acme.examples.offline import helpers as gym_helpers
from acme.jax import variable... | null |
28,905 | from absl import flags
from acme.agents.jax import td3
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
FLAGS = flags.FLAGS
The provided code snippet includes necessary dependencies for implementing the `build_experiment_config` function. Write... | Builds TD3 experiment config which can be executed in different ways. |
28,906 | from absl import flags
from acme import specs
from acme.agents.jax import normalization
from acme.agents.jax import sac
from acme.agents.jax.sac import builder
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
FLAGS = flags.FLAGS
The provided co... | Builds SAC experiment config which can be executed in different ways. |
28,907 | from absl import flags
from acme import specs
from acme.agents.jax import mpo
from acme.agents.jax.mpo import types as mpo_types
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string(
'env_name', 'gym:HalfCheetah-v2... | Builds MPO experiment config which can be executed in different ways. |
28,908 | from absl import flags
from acme.agents.jax import ppo
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
FLAGS = flags.FLAGS
The provided code snippet includes necessary dependencies for implementing the `build_experiment_config` function. Write... | Builds PPO experiment config which can be executed in different ways. |
28,909 | from absl import flags
from acme import specs
from acme.agents.jax import mpo
from acme.agents.jax.mpo import types as mpo_types
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string(
'env_name', 'gym:HalfCheetah-v2... | Builds MPO experiment config which can be executed in different ways. |
28,910 | from absl import flags
from acme.agents.jax import d4pg
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
FLAGS = flags.FLAGS
The provided code snippet includes necessary dependencies for implementing the `build_experiment_config` function. Writ... | Builds D4PG experiment config which can be executed in different ways. |
28,911 | from absl import flags
from acme import specs
from acme.agents.jax import mpo
from acme.agents.jax.mpo import types as mpo_types
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string(
'env_name', 'gym:HalfCheetah-v2... | Builds MPO experiment config which can be executed in different ways. |
28,912 | from typing import Callable, Iterator, Tuple
from absl import flags
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import bc
from acme.datasets import tfds
import helpers
from absl import app
from acme.jax import experiments
from acme.jax impo... | Returns a config for BC experiments. |
28,913 | from absl import flags
from acme import specs
from acme.agents.jax import ail
from acme.agents.jax import td3
from acme.datasets import tfds
import helpers
from absl import app
from acme.jax import experiments
from acme.jax import networks as networks_lib
from acme.utils import lp_utils
import dm_env
import haiku as hk... | Returns a configuration for GAIL/DAC experiments. |
28,914 | from typing import Callable, Iterator
from absl import flags
from acme import specs
from acme import types
from acme.agents.jax import actor_core as actor_core_lib
from acme.agents.jax import iq_learn
from acme.datasets import tfds
import helpers
from absl import app
from acme.jax import experiments
from acme.jax impor... | Returns a configuration for IQLearn experiments. |
28,915 | from typing import Sequence
from absl import flags
from acme import specs
from acme.agents.jax import d4pg
from acme.agents.jax import pwil
from acme.datasets import tfds
import helpers
from absl import app
from acme.jax import experiments
from acme.jax import networks as networks_lib
from acme.jax import utils
from ac... | Returns a configuration for PWIL experiments. |
28,916 | from absl import flags
from acme import specs
from acme.agents.jax import sac
from acme.agents.jax import sqil
from acme.datasets import tfds
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import dm_env
import jax
import launchpad as lp
FLAGS = flags.FLAGS
The prov... | Returns a configuration for SQIL experiments. |
28,917 | from absl import flags
from acme.agents.jax import impala
from acme.agents.jax.impala import builder as impala_builder
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
import optax
ENV_NAME = flags.DEFINE_string('env_name', 'Pong', 'What environ... | Builds IMPALA experiment config which can be executed in different ways. |
28,918 | import datetime
import math
from absl import flags
from acme import specs
from acme.agents.jax import muzero
import helpers
from absl import app
from acme.jax import experiments
from acme.jax import inference_server as inference_server_lib
from acme.utils import lp_utils
import dm_env
import launchpad as lp
ENV_NAME = ... | Builds DQN experiment config which can be executed in different ways. |
28,919 | from absl import flags
from acme import specs
from acme.agents.jax import dqn
from acme.agents.jax.dqn import losses
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string('env_name', 'Pong', 'What environment to run')
S... | Builds QR-DQN experiment config which can be executed in different ways. |
28,920 | from absl import flags
from acme.agents.jax import dqn
from acme.agents.jax.dqn import losses
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string('env_name', 'Pong', 'What environment to run')
SEED = flags.DEFINE_inte... | Builds DQN experiment config which can be executed in different ways. |
28,921 | from absl import flags
from acme.agents.jax import r2d2
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import dm_env
import launchpad as lp
FLAGS = flags.FLAGS
The provided code snippet includes necessary dependencies for implementing the `build_experiment_config` ... | Builds R2D2 experiment config which can be executed in different ways. |
28,922 | from absl import flags
from acme.agents.jax import dqn
from acme.agents.jax.dqn import losses
import helpers
from absl import app
from acme.jax import experiments
from acme.utils import lp_utils
import launchpad as lp
ENV_NAME = flags.DEFINE_string('env_name', 'Pong', 'What environment to run')
SEED = flags.DEFINE_inte... | Builds MDQN experiment config which can be executed in different ways. |
28,923 | from acme import specs
from acme.multiagent import types
import dm_env
The provided code snippet includes necessary dependencies for implementing the `get_agent_timestep` function. Write a Python function `def get_agent_timestep(timestep: dm_env.TimeStep, agent_id: types.AgentID) -> dm_env.TimeS... | Returns the extracted timestep for a particular agent. |
28,924 | import operator
import time
from typing import List, Optional, Sequence
from acme import core
from acme.utils import counting
from acme.utils import loggers
from acme.utils import observers as observers_lib
from acme.utils import signals
import dm_env
from dm_env import specs
import numpy as np
import tree
def _genera... | null |
28,925 | from typing import NamedTuple, Optional, Tuple, Union
import jax
import jax.numpy as jnp
import tensorflow_probability
The provided code snippet includes necessary dependencies for implementing the `compute_weights_and_temperature_loss` function. Write a Python function `def compute_weights_and_temperature_loss( q... | Computes normalized importance weights for the policy optimization. Args: q_values: Q-values associated with the actions sampled from the target policy; expected shape [N, B]. epsilon: Desired constraint on the KL between the target and non-parametric policies. temperature: Scalar used to temper the Q-values before com... |
28,926 | from typing import NamedTuple, Optional, Tuple, Union
import jax
import jax.numpy as jnp
import tensorflow_probability
The provided code snippet includes necessary dependencies for implementing the `compute_nonparametric_kl_from_normalized_weights` function. Write a Python function `def compute_nonparametric_kl_from_n... | Estimate the actualized KL between the non-parametric and target policies. |
28,927 | from typing import NamedTuple, Optional, Tuple, Union
import jax
import jax.numpy as jnp
import tensorflow_probability
tfd = tensorflow_probability.substrates.jax.distributions
The provided code snippet includes necessary dependencies for implementing the `compute_cross_entropy_loss` function. Write a Python function ... | Compute cross-entropy online and the reweighted target policy. Args: sampled_actions: samples used in the Monte Carlo integration in the policy loss. Expected shape is [N, B, ...], where N is the number of sampled actions and B is the number of sampled states. normalized_weights: target policy multiplied by the exponen... |
28,928 | from typing import NamedTuple, Optional, Tuple, Union
import jax
import jax.numpy as jnp
import tensorflow_probability
The provided code snippet includes necessary dependencies for implementing the `compute_parametric_kl_penalty_and_dual_loss` function. Write a Python function `def compute_parametric_kl_penalty_and_du... | Computes the KL cost to be added to the Lagragian and its dual loss. The KL cost is simply the alpha-weighted KL divergence and it is added as a regularizer to the policy loss. The dual variable alpha itself has a loss that can be minimized to adapt the strength of the regularizer to keep the KL between consecutive upd... |
28,929 | from typing import NamedTuple, Optional, Tuple, Union
import jax
import jax.numpy as jnp
import tensorflow_probability
_MIN_LOG_TEMPERATURE = -18.0
_MIN_LOG_ALPHA = -18.0
class MPOParams(NamedTuple):
def clip_mpo_params(params: MPOParams, per_dim_constraining: bool) -> MPOParams:
clipped_params = MPOParams(
lo... | null |
28,930 | from typing import Callable, Mapping, Tuple
from acme.agents.jax.impala import types
from acme.jax import utils
import haiku as hk
import jax
import jax.numpy as jnp
import numpy as np
import reverb
import rlax
import tree
The provided code snippet includes necessary dependencies for implementing the `impala_loss` fun... | Builds the standard entropy-regularised IMPALA loss function. Args: unroll_fn: A `hk.Transformed` object containing a callable which maps (params, observations_sequence, initial_state) -> ((logits, value), state) discount: The standard geometric discount rate to apply. max_abs_reward: Optional symmetric reward clipping... |
28,931 | import functools
import itertools
import queue
import threading
from typing import Callable, Iterable, Iterator, NamedTuple, Optional, Sequence, Tuple, TypeVar
from absl import logging
from acme import core
from acme import types
from acme.jax import types as jax_types
import haiku as hk
import jax
import jax.numpy as ... | Converts to numpy and squeezes out dummy batch dimension. |
28,932 | import functools
import itertools
import queue
import threading
from typing import Callable, Iterable, Iterator, NamedTuple, Optional, Sequence, Tuple, TypeVar
from absl import logging
from acme import core
from acme import types
from acme.jax import types as jax_types
import haiku as hk
import jax
import jax.numpy as ... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.