Search is not available for this dataset
repo
stringlengths
2
152
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
null
coax-main/coax/proba_dists/_normal.py
import warnings import jax import jax.numpy as jnp import numpy as onp from gymnasium.spaces import Box from ..utils import clipped_logit, jit from ._base import BaseProbaDist __all__ = ( 'NormalDist', ) class NormalDist(BaseProbaDist): r""" A differentiable normal distribution. The input ``dist...
13,182
33.692105
100
py
null
coax-main/coax/proba_dists/_normal_test.py
import gymnasium import jax import haiku as hk from .._base.test_case import TestCase from ._normal import NormalDist class TestNormalDist(TestCase): decimal = 5 def setUp(self): self.rngs = hk.PRNGSequence(13) def tearDown(self): del self.rngs def test_kl_divergence(self): ...
1,443
33.380952
89
py
null
coax-main/coax/proba_dists/_squashed_normal.py
import jax import jax.numpy as jnp import numpy as onp from ._base import BaseProbaDist from ._normal import NormalDist class SquashedNormalDist(BaseProbaDist): r""" A differentiable squashed normal distribution. The input ``dist_params`` to each of the functions is expected to be of the form: .. ...
7,209
26.519084
100
py
null
coax-main/coax/regularizers/__init__.py
r""" Regularizers ============ .. autosummary:: :nosignatures: coax.regularizers.EntropyRegularizer coax.regularizers.KLDivRegularizer ---- This is a collection of regularizers that can be used to put soft constraints on stochastic function approximators. These is typically added to the loss/objective t...
789
19.789474
100
py
null
coax-main/coax/regularizers/_base.py
import haiku as hk from ..utils import is_stochastic, jit from .._core.base_stochastic_func_type1 import BaseStochasticFuncType1 from .._core.base_stochastic_func_type2 import BaseStochasticFuncType2 class Regularizer: r""" Abstract base class for policy regularizers. Check out :class:`coax.regularizers...
2,979
32.111111
100
py
null
coax-main/coax/regularizers/_entropy.py
import jax.numpy as jnp from ..utils import jit from ._base import Regularizer class EntropyRegularizer(Regularizer): r""" Policy regularization term based on the entropy of the policy. The regularization term is to be added to the loss function: .. math:: \text{loss}(\theta; s,a)\ =\ -J(...
2,326
25.146067
95
py
null
coax-main/coax/regularizers/_kl_div.py
import jax.numpy as jnp from ..utils import jit from ._base import Regularizer class KLDivRegularizer(Regularizer): r""" Policy regularization term based on the Kullback-Leibler divergence of the policy relative to a given set of priors. The regularization term is to be added to the loss function: ...
3,192
28.564815
99
py
null
coax-main/coax/regularizers/_nstep_entropy.py
import haiku as hk import jax import jax.numpy as jnp from .._core.base_stochastic_func_type2 import BaseStochasticFuncType2 from ..utils import jit from ._entropy import EntropyRegularizer class NStepEntropyRegularizer(EntropyRegularizer): r""" Policy regularization term based on the n-step entropy of the ...
5,091
37.575758
96
py
null
coax-main/coax/reward_tracing/__init__.py
r""" Reward Tracing ============== .. autosummary:: :nosignatures: coax.reward_tracing.NStep coax.reward_tracing.MonteCarlo coax.reward_tracing.TransitionBatch ---- The term **reward tracing** refers to the process of turning raw experience into :class:`TransitionBatch <coax.reward_tracing.Transitio...
1,509
22.968254
99
py
null
coax-main/coax/reward_tracing/_base.py
from abc import ABC, abstractmethod import jax import numpy as onp from .._base.errors import InsufficientCacheError __all__ = ( 'BaseRewardTracer', ) class BaseRewardTracer(ABC): @abstractmethod def reset(self): r""" Reset the cache to the initial state. """ pass ...
1,848
18.670213
90
py
null
coax-main/coax/reward_tracing/_montecarlo.py
from .._base.errors import InsufficientCacheError, EpisodeDoneError from ._base import BaseRewardTracer from ._transition import TransitionBatch __all__ = ( 'MonteCarlo', ) class MonteCarlo(BaseRewardTracer): r""" A short-term cache for episodic Monte Carlo sampling. Parameters ---------- g...
1,854
27.538462
99
py
null
coax-main/coax/reward_tracing/_montecarlo_test.py
from itertools import islice import pytest import gymnasium import jax.numpy as jnp from numpy.testing import assert_array_almost_equal from .._base.errors import InsufficientCacheError from ..utils import check_array from ._montecarlo import MonteCarlo class MockEnv: action_space = gymnasium.spaces.Discrete(10...
3,645
35.828283
93
py
null
coax-main/coax/reward_tracing/_nstep.py
from collections import deque from itertools import islice import numpy as onp from .._base.errors import InsufficientCacheError, EpisodeDoneError from ._base import BaseRewardTracer from ._transition import TransitionBatch __all__ = ( 'NStep', ) class NStep(BaseRewardTracer): r""" A short-term cache ...
4,059
30.968504
99
py
null
coax-main/coax/reward_tracing/_nstep_test.py
from itertools import islice import pytest import gymnasium import jax.numpy as jnp from numpy.testing import assert_array_almost_equal from .._base.errors import InsufficientCacheError, EpisodeDoneError from ..utils import check_array from ._nstep import NStep class MockEnv: action_space = gymnasium.spaces.Dis...
11,381
40.845588
93
py
null
coax-main/coax/reward_tracing/_transition.py
from functools import partial import jax import jax.numpy as jnp import numpy as onp from .._base.mixins import CopyMixin from ..utils import pretty_repr __all__ = ( 'TransitionBatch', ) class TransitionBatch(CopyMixin): r""" A container object for a batch of MDP transitions. Parameters ----...
7,570
29.651822
97
py
null
coax-main/coax/td_learning/__init__.py
r""" TD Learning =========== .. autosummary:: :nosignatures: coax.td_learning.SimpleTD coax.td_learning.Sarsa coax.td_learning.ExpectedSarsa coax.td_learning.QLearning coax.td_learning.DoubleQLearning coax.td_learning.SoftQLearning coax.td_learning.ClippedDoubleQLearning coax.td_le...
1,702
27.383333
98
py
null
coax-main/coax/td_learning/_base.py
from abc import ABC, abstractmethod import jax import jax.numpy as jnp import haiku as hk import optax import chex from .._base.mixins import RandomStateMixin from ..utils import get_grads_diagnostics, is_policy, is_stochastic, is_qfunction, is_vfunction, jit from ..value_losses import huber, quantile_huber from ..re...
22,895
40.32852
100
py
null
coax-main/coax/td_learning/_clippeddoubleqlearning.py
import warnings import jax import jax.numpy as jnp import haiku as hk import chex from gymnasium.spaces import Discrete from ..proba_dists import DiscretizedIntervalDist, EmpiricalQuantileDist from ..utils import (get_grads_diagnostics, is_policy, is_qfunction, is_stochastic, jit, single_to_batch...
17,026
46.166205
100
py
null
coax-main/coax/td_learning/_clippeddoubleqlearning_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.stochastic_q import StochasticQ from .._core.policy import Policy from ..utils import get_transition_batch from ._clippeddoubleqlearning import ClippedDoubleQLearning class TestClippedDoubleQL...
8,951
37.586207
98
py
null
coax-main/coax/td_learning/_doubleqlearning.py
import warnings import haiku as hk import chex from gymnasium.spaces import Discrete from ..utils import is_stochastic from ._base import BaseTDLearningQWithTargetPolicy class DoubleQLearning(BaseTDLearningQWithTargetPolicy): r""" TD-learning with `Double-DQN <https://arxiv.org/abs/1509.06461>`_ style doub...
5,168
37.288889
100
py
null
coax-main/coax/td_learning/_doubleqlearning_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.policy import Policy from ..utils import get_transition_batch from ._doubleqlearning import DoubleQLearning class TestDoubleQLearning(TestCase): def setUp(self): self.transition_d...
3,070
29.107843
90
py
null
coax-main/coax/td_learning/_expectedsarsa.py
import gymnasium import jax import haiku as hk from ..utils import is_stochastic from ._base import BaseTDLearningQWithTargetPolicy class ExpectedSarsa(BaseTDLearningQWithTargetPolicy): r""" TD-learning with expected-SARSA updates. The :math:`n`-step bootstrapped target is constructed as: .. math::...
4,207
34.361345
100
py
null
coax-main/coax/td_learning/_expectedsarsa_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.policy import Policy from ..utils import get_transition_batch from ..regularizers import EntropyRegularizer from ._expectedsarsa import ExpectedSarsa class TestExpectedSarsa(TestCase): de...
4,302
35.159664
98
py
null
coax-main/coax/td_learning/_qlearning.py
import warnings import haiku as hk import chex from gymnasium.spaces import Discrete from ..utils import is_stochastic from ._base import BaseTDLearningQWithTargetPolicy class QLearning(BaseTDLearningQWithTargetPolicy): r""" TD-learning with Q-Learning updates. The :math:`n`-step bootstrapped target f...
5,556
36.802721
100
py
null
coax-main/coax/td_learning/_qlearning_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.policy import Policy from ..utils import get_transition_batch from ._qlearning import QLearning class TestQLearning(TestCase): def setUp(self): self.transition_discrete = get_tran...
3,016
28.578431
90
py
null
coax-main/coax/td_learning/_sarsa.py
import haiku as hk from ..utils import is_stochastic from ._base import BaseTDLearningQ class Sarsa(BaseTDLearningQ): r""" TD-learning with SARSA updates. The :math:`n`-step bootstrapped target is constructed as: .. math:: G^{(n)}_t\ =\ R^{(n)}_t + I^{(n)}_t\,q_\text{targ}(S_{t+n}, A_{t+n}) ...
2,826
33.901235
100
py
null
coax-main/coax/td_learning/_sarsa_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.policy import Policy from ..utils import get_transition_batch from ..regularizers import EntropyRegularizer from ._sarsa import Sarsa class TestSarsa(TestCase): def setUp(self): s...
5,906
38.119205
98
py
null
coax-main/coax/td_learning/_simple_td.py
import haiku as hk from ..utils import is_stochastic from ._base import BaseTDLearningV class SimpleTD(BaseTDLearningV): r""" TD-learning for state value functions :math:`v(s)`. The :math:`n`-step bootstrapped target is constructed as: .. math:: G^{(n)}_t\ =\ R^{(n)}_t + I^{(n)}_t\,v_\text...
2,704
31.987805
99
py
null
coax-main/coax/td_learning/_simple_td_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.v import V from .._core.policy import Policy from ..utils import get_transition_batch from ..regularizers import EntropyRegularizer from ..value_transforms import LogTransform from ._simple_td import SimpleTD class T...
6,622
39.384146
98
py
null
coax-main/coax/td_learning/_softclippeddoubleqlearning.py
import haiku as hk import jax import jax.numpy as jnp from gymnasium.spaces import Discrete from ..utils import (batch_to_single, is_stochastic, single_to_batch, stack_trees) from ._clippeddoubleqlearning import ClippedDoubleQLearning class SoftClippedDoubleQLearning(ClippedDoubleQLearning): ...
6,368
51.204918
99
py
null
coax-main/coax/td_learning/_softqlearning.py
import haiku as hk from jax.scipy.special import logsumexp from gymnasium.spaces import Discrete from ..utils import is_stochastic from ._base import BaseTDLearningQ class SoftQLearning(BaseTDLearningQ): r""" TD-learning with soft Q-learning updates. The :math:`n`-step bootstrapped target is constructed ...
3,698
33.570093
100
py
null
coax-main/coax/td_learning/_softqlearning_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.q import Q from .._core.policy import Policy from ..utils import get_transition_batch from ..regularizers import EntropyRegularizer from ._softqlearning import SoftQLearning class TestSoftQLearning(TestCase): de...
3,958
36.704762
98
py
null
coax-main/coax/utils/__init__.py
r""" Utilities ========= This is a collection of utility (helper) functions used throughout the package. .. autosummary:: :nosignatures: coax.utils.OrnsteinUhlenbeckNoise coax.utils.StepwiseLinearFunction coax.utils.SegmentTree coax.utils.SumTree coax.utils.MinTree coax.utils.MaxTree ...
6,051
25.086207
81
py
null
coax-main/coax/utils/_action_noise.py
import numpy as onp __all__ = ( 'OrnsteinUhlenbeckNoise', ) class OrnsteinUhlenbeckNoise: r""" Add `Ornstein-Uhlenbeck <https://en.wikipedia.org/wiki/Ornstein-Uhlenbeck_process>`_ noise to continuous actions. .. math:: A_t\ \mapsto\ \widetilde{A}_t = A_t + X_t As a side effect, t...
3,119
27.108108
100
py
null
coax-main/coax/utils/_action_noise_test.py
import jax.numpy as jnp from .._base.test_case import TestCase from ._action_noise import OrnsteinUhlenbeckNoise class TestOrnsteinUhlenbeckNoise(TestCase): def test_overall_mean_variance(self): noise = OrnsteinUhlenbeckNoise(random_seed=13) x = jnp.stack([noise(0.) for _ in range(1000)]) ...
498
32.266667
55
py
null
coax-main/coax/utils/_array.py
import warnings from collections import Counter from functools import partial import chex import gymnasium import jax import jax.numpy as jnp import numpy as onp import haiku as hk from scipy.linalg import pascal __all__ = ( 'StepwiseLinearFunction', 'argmax', 'argmin', 'batch_to_single', 'check_...
34,240
28.774783
100
py
null
coax-main/coax/utils/_array_test.py
import gymnasium import jax import jax.numpy as jnp import numpy as onp from haiku import PRNGSequence from .._base.test_case import TestCase from ..proba_dists import NormalDist from ._array import ( argmax, check_preprocessors, chunks_pow2, default_preprocessor, get_transition_batch, tree_sam...
5,291
42.377049
100
py
null
coax-main/coax/utils/_array_test_unvectorize.py
import pytest import jax import haiku as hk from ._array import unvectorize @pytest.fixture def rngs(): return hk.PRNGSequence(42) @pytest.fixture def x_batch(): rng = jax.random.PRNGKey(13) return jax.random.normal(rng, shape=(7, 11)) @pytest.fixture def x_single(): rng = jax.random.PRNGKey(17) ...
2,542
31.602564
93
py
null
coax-main/coax/utils/_dmc_gym.py
""" Adapted from https://github.com/denisyarats/dmc2gym/blob/master/dmc2gym/wrappers.py """ import numpy as onp from dm_control import suite from dm_env import specs from gymnasium import spaces, Env from gymnasium.envs.registration import register, make, registry def make_dmc(domain, task, seed=0, max_episode_step...
3,936
29.757813
98
py
null
coax-main/coax/utils/_jit.py
from inspect import signature import jax __all__ = ( 'JittedFunc', 'jit', ) def jit(func, static_argnums=(), donate_argnums=()): r""" An alternative of :func:`jax.jit` that returns a picklable JIT-compiled function. Note that :func:`jax.jit` produces non-picklable functions, because the JIT ...
2,163
26.05
99
py
null
coax-main/coax/utils/_misc.py
import os import time import logging from importlib import reload, import_module from types import ModuleType import jax.numpy as jnp import numpy as onp import pandas as pd import lz4.frame import cloudpickle as pickle from PIL import Image __all__ = ( 'docstring', 'enable_logging', 'dump', 'dumps',...
18,988
23.470361
100
py
null
coax-main/coax/utils/_misc_test.py
import os import tempfile from ..utils import jit from ._misc import dump, dumps, load, loads def test_dump_load(): with tempfile.TemporaryDirectory() as d: a = [13] b = {'a': a} # references preserved dump((a, b), os.path.join(d, 'ab.pkl.lz4')) a_new, b_new = load(os.pat...
1,377
21.966667
58
py
null
coax-main/coax/utils/_quantile_funcs.py
import haiku as hk import jax import jax.numpy as jnp import numpy as onp __all__ = ( 'quantiles', 'quantiles_uniform', 'quantile_cos_embedding' ) def quantiles_uniform(rng, batch_size, num_quantiles=32): """ Generate :code:`batch_size` quantile fractions that split the interval :math:`[0, 1]` ...
2,764
27.505155
90
py
null
coax-main/coax/utils/_rolling.py
from collections import deque class RollingAverage: def __init__(self, n=100): self._value = 0. self._deque = deque(maxlen=n) @property def value(self): return self._value def update(self, observed_value): if len(self._deque) == self._deque.maxlen: self._v...
992
25.131579
88
py
null
coax-main/coax/utils/_segment_tree.py
import numpy as onp __all__ = ( 'SegmentTree', 'SumTree', 'MinTree', 'MaxTree', ) class SegmentTree: r""" A `segment tree <https://en.wikipedia.org/wiki/Segment_tree>`_ data structure that allows for batched updating and batched partial-range (segment) reductions. Parameters --...
15,361
33.290179
99
py
null
coax-main/coax/utils/_segment_tree_test.py
import pytest import numpy as onp import pandas as pd from ._segment_tree import SumTree, MinTree @pytest.fixture def sum_tree(): return SumTree(capacity=14) @pytest.fixture def min_tree(): tr = MinTree(capacity=8) tr.set_values(..., onp.array([13, 7, 11, 17, 19, 5, 3, 23])) return tr def test_su...
4,278
29.564286
100
py
null
coax-main/coax/value_losses/__init__.py
r""" Value Losses ============ .. autosummary:: :nosignatures: coax.value_losses.mse coax.value_losses.huber coax.value_losses.logloss coax.value_losses.logloss_sign coax.value_losses.quantile_huber ---- This is a collection of loss functions that may be used for learning a value function. T...
825
19.146341
100
py
null
coax-main/coax/value_losses/_losses.py
import jax import jax.numpy as jnp __all__ = ( 'mse', 'huber', 'logloss', 'logloss_sign', ) def mse(y_true, y_pred, w=None): r""" Ordinary mean-squared error loss function. .. math:: L\ =\ \frac12(\hat{y} - y)^2 .. image:: /_static/img/mse.svg :alt: Mean-Squared E...
5,578
21.864754
97
py
null
coax-main/coax/value_transforms/__init__.py
r""" Value Transforms ================ .. autosummary:: :nosignatures: coax.value_transforms.ValueTransform coax.value_transforms.LogTransform ---- This module contains some useful **value transforms**. These are functions that can be used to rescale or warp the returns for more a more robust training s...
659
18.411765
79
py
null
coax-main/coax/value_transforms/_base.py
class ValueTransform: r""" Abstract base class for value transforms. See :class:`coax.value_transforms.LogTransform` for a specific implementation. """ __slots__ = ('_transform_func', '_inverse_func') def __init__(self, transform_func, inverse_func): self._transform_func = transform_...
1,263
20.423729
78
py
null
coax-main/coax/value_transforms/_log_transform.py
import jax.numpy as jnp from ._base import ValueTransform class LogTransform(ValueTransform): r""" A simple invertible log-transform. .. math:: x\ \mapsto\ y\ =\ \lambda\,\text{sign}(x)\, \log\left(1+\frac{|x|}{\lambda}\right) with inverse: .. math:: y\ \mapsto\...
1,385
24.666667
99
py
null
coax-main/coax/value_transforms/_log_transform_test.py
import jax.numpy as jnp from .._base.test_case import TestCase from ._log_transform import LogTransform class TestLogTransform(TestCase): decimal = 5 def test_inverse(self): f = LogTransform(scale=7) # some consistency checks values = jnp.array([-100, -10, -1, 0, 1, 10, 100], dtype='...
429
25.875
75
py
null
coax-main/coax/wrappers/__init__.py
r""" Wrappers ======== .. autosummary:: :nosignatures: coax.wrappers.TrainMonitor coax.wrappers.FrameStacking coax.wrappers.BoxActionsToReals coax.wrappers.BoxActionsToDiscrete coax.wrappers.MetaPolicyEnv ---- Gymnasium provides a nice modular interface to extend existing using `environment ...
1,366
25.288462
78
py
null
coax-main/coax/wrappers/_box_spaces.py
import gymnasium import numpy as onp from scipy.special import expit as sigmoid from .._base.mixins import AddOrigToInfoDictMixin __all__ = ( 'BoxActionsToReals', 'BoxActionsToDiscrete', ) class BoxActionsToReals(gymnasium.Wrapper, AddOrigToInfoDictMixin): r""" This wrapper decompactifies a :class...
4,466
38.184211
100
py
null
coax-main/coax/wrappers/_box_spaces_test.py
from itertools import combinations import gymnasium import numpy as onp from .._base.test_case import TestCase from ._box_spaces import BoxActionsToDiscrete class TestBoxActionsToDiscrete(TestCase): def test_inverse(self): num_bins = 100 env = gymnasium.make('BipedalWalker-v3') env = Bo...
1,259
29
70
py
null
coax-main/coax/wrappers/_frame_stacking.py
from collections import deque import gymnasium class FrameStacking(gymnasium.Wrapper): r""" Wrapper that does frame stacking (see `DQN paper <https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf>`_). This implementation is different from most implementations in that it doesn't perform the stacking it...
2,186
34.274194
99
py
null
coax-main/coax/wrappers/_meta_policy.py
import inspect import gymnasium class MetaPolicyEnv(gymnasium.Wrapper): r""" Wrap a gymnasium-style environment such that it may be used by a meta-policy, i.e. a bandit that selects a policy (an *arm*), which is then used to sample a lower-level action and fed the original environment. In other ...
1,824
32.181818
81
py
null
coax-main/coax/wrappers/_train_monitor.py
import os import re import datetime import logging import time from collections import deque from typing import Mapping import numpy as np import lz4.frame import cloudpickle as pickle from gymnasium import Wrapper from gymnasium.spaces import Discrete from tensorboardX import SummaryWriter from .._base.mixins import...
12,563
28.84323
99
py
null
coax-main/doc/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
10,762
32.321981
100
py
null
coax-main/doc/create_notebooks.py
#!/usr/bin/env python3 import os import json import shutil from glob import glob from copy import deepcopy PACKAGEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) nb_template = { "cells": [ { "cell_type": "code", "execution_count": None, "metadata": {...
2,859
25.481481
85
py
null
coax-main/doc/versions.html
<style> .version.matrix { width: 100%; } .version.options { column-fill: balance; column-gap: 0; text-align: center; } .version.title { width: 25%; padding: 10px 10px 10px 0px; } .version.option { background: #E3E3E3; padding: 10px 5px 10px 5px; margin: 0px 1px; } .version.option:hover { color: #FFF...
4,720
29.458065
170
html
null
coax-main/doc/_static/css/custom.css
body a { font-weight: bold; } .math { text-align: left; } .eqno { float: right; } .keep-us-sustainable { /* hide ads */ display: none !important; } .wy-nav-top { max-width: 900px; } .wy-nav-content { background: #fff; max-width: 900px; } .rst-content dl:not(.docutils) dl dt strong { padding-...
622
13.159091
82
css
null
coax-main/doc/examples/README.md
# Example Notebooks To interact with these examples, please go to: * https://coax.readthedocs.io From there you can view them easily and open the scripts as Jupyter notebooks in Google Colab.
195
23.5
94
md
null
coax-main/doc/examples/sandbox.py
0
0
0
py
null
coax-main/doc/examples/atari/apex_dqn.py
import os os.environ['JAX_PLATFORM_NAME'] = 'cpu' # os.environ['JAX_PLATFORM_NAME'] = 'gpu' # os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem import gymnasium import ray import jax import jax.numpy as jnp import coax import haiku as hk import optax # name of this script name, _ = os.pa...
3,880
31.613445
116
py
null
coax-main/doc/examples/atari/ddpg.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
3,394
29.863636
99
py
null
coax-main/doc/examples/atari/dqn.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
2,794
29.380435
112
py
null
coax-main/doc/examples/atari/dqn_boltzmann.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
2,705
30.103448
112
py
null
coax-main/doc/examples/atari/dqn_per.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
3,070
31.670213
112
py
null
coax-main/doc/examples/atari/dqn_soft.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
2,700
29.693182
112
py
null
coax-main/doc/examples/atari/dqn_type1.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
2,736
29.752809
112
py
null
coax-main/doc/examples/atari/ppo.py
import os # set some env vars os.environ.setdefault('JAX_PLATFORM_NAME', 'gpu') # tell JAX to use GPU os.environ['XLA_PYTHON_CLIENT_MEM_FRACTION'] = '0.1' # don't use all gpu mem os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # tell XLA to be quiet import gymnasium import jax import coax import haiku as h...
3,521
29.362069
94
py
null
coax-main/doc/examples/atari/run_all.sh
#!/bin/bash trap "kill 0" EXIT gio trash -f ./data for f in $(ls ./*.py); do python3 $f & done wait
107
8.818182
25
sh
null
coax-main/doc/examples/atari/experiment/dqn_sqil.py
0
0
0
py
null
coax-main/doc/examples/cartpole/a2c.py
import coax import gymnasium import haiku as hk import jax import jax.numpy as jnp import optax from coax.value_losses import mse # the name of this script name = 'a2c' # the cart-pole MDP env = gymnasium.make('CartPole-v0', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorboard_dir=f"...
2,386
26.436782
94
py
null
coax-main/doc/examples/cartpole/dqn.py
import coax import gymnasium import haiku as hk import jax import jax.numpy as jnp from coax.value_losses import mse from optax import adam # the name of this script name = 'dqn' # the cart-pole MDP env = gymnasium.make('CartPole-v0', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorbo...
2,219
25.428571
98
py
null
coax-main/doc/examples/cartpole/iqn.py
import coax import gymnasium import haiku as hk import jax import jax.numpy as jnp import numpy as onp from optax import adam # the name of this script name = 'iqn' # the cart-pole MDP env = gymnasium.make('CartPole-v0', render_mode='rgb_array') env = coax.wrappers.TrainMonitor( env, name=name, tensorboard_dir=f"...
3,092
29.029126
91
py
null
coax-main/doc/examples/cartpole/model_based.py
import coax import gymnasium import jax.numpy as jnp import haiku as hk import optax from coax.value_losses import mse # the name of this script name = 'model_based' # the cart-pole MDP env = gymnasium.make('CartPole-v0', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorboard_dir=f"./d...
2,228
26.518519
97
py
null
coax-main/doc/examples/cartpole/run_all.sh
#!/bin/bash trap "kill 0" EXIT gio trash -f ./data for f in $(ls ./*.py); do JAX_PLATFORM_NAME=cpu python3 $f & done wait
129
10.818182
38
sh
null
coax-main/doc/examples/dmc/run_all.sh
#!/bin/bash trap "kill 0" EXIT gio trash -f ./data for f in $(ls ./*.py); do JAX_PLATFORM_NAME=cpu python3 $f & done wait
129
10.818182
38
sh
null
coax-main/doc/examples/dmc/sac.py
import os os.environ["MUJOCO_GL"] = "egl" import coax import haiku as hk import jax import jax.numpy as jnp import numpy as onp import optax from coax.utils import make_dmc # the name of this script name = 'sac' # the dm_control MDP env = make_dmc("walker", "walk") env = coax.wrappers.TrainMonitor(env, name=name) ...
3,943
31.595041
95
py
null
coax-main/doc/examples/frozen_lake/a2c.py
import coax import jax import jax.numpy as jnp import gymnasium import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func_v(S, is_training): value = hk.Sequential((hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) return value(S) de...
2,313
21.910891
82
py
null
coax-main/doc/examples/frozen_lake/ddpg.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func_pi(S, is_training): logits = hk.Linear(env.action_space.n, w_init=jnp.zeros) return {'logits': logits(S)} ...
2,594
23.252336
86
py
null
coax-main/doc/examples/frozen_lake/double_qlearning.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): value = hk.Sequential((hk.Flatten(), hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) X = j...
1,943
20.6
90
py
null
coax-main/doc/examples/frozen_lake/expected_sarsa.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): value = hk.Sequential((hk.Flatten(), hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) X = j...
1,809
20.807229
84
py
null
coax-main/doc/examples/frozen_lake/ppo.py
import coax import jax import jax.numpy as jnp import gymnasium import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func_v(S, is_training): value = hk.Sequential((hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) return value(S) de...
2,415
22.456311
82
py
null
coax-main/doc/examples/frozen_lake/qlearning.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): value = hk.Sequential((hk.Flatten(), hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) X = j...
1,807
20.783133
84
py
null
coax-main/doc/examples/frozen_lake/reinforce.py
import coax import jax import jax.numpy as jnp import gymnasium import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func_pi(S, is_training): logits = hk.Linear(env.action_space.n, w_init=jnp.zeros) return {'logits': logits(S)} ...
1,820
20.939759
77
py
null
coax-main/doc/examples/frozen_lake/run_all.sh
#!/bin/bash trap "kill 0" EXIT gio trash -f ./data for f in $(ls ./*.py); do JAX_PLATFORM_NAME=cpu python3 $f & done wait
129
10.818182
38
sh
null
coax-main/doc/examples/frozen_lake/sarsa.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): value = hk.Sequential((hk.Flatten(), hk.Linear(1, w_init=jnp.zeros), jnp.ravel)) X = j...
1,795
20.638554
84
py
null
coax-main/doc/examples/frozen_lake/stochastic_double_qlearning.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax from matplotlib import pyplot as plt # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): logits = hk.Sequential((hk.Flatten(), hk.Linear(20, w...
2,469
22.75
90
py
null
coax-main/doc/examples/frozen_lake/stochastic_expected_sarsa.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax from matplotlib import pyplot as plt # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): logits = hk.Sequential((hk.Flatten(), hk.Linear(20, w...
2,335
23.082474
82
py
null
coax-main/doc/examples/frozen_lake/stochastic_qlearning.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax from matplotlib import pyplot as plt # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): logits = hk.Sequential((hk.Flatten(), hk.Linear(20, w...
2,325
22.979381
82
py
null
coax-main/doc/examples/frozen_lake/stochastic_sarsa.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax from matplotlib import pyplot as plt # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func(S, A, is_training): logits = hk.Sequential((hk.Flatten(), hk.Linear(20, w...
2,321
22.938144
82
py
null
coax-main/doc/examples/frozen_lake/td3.py
import coax import gymnasium import jax import jax.numpy as jnp import haiku as hk import optax # the MDP env = gymnasium.make('FrozenLakeNonSlippery-v0') env = coax.wrappers.TrainMonitor(env) def func_pi(S, is_training): logits = hk.Linear(env.action_space.n, w_init=jnp.zeros) return {'logits': logits(S)} ...
3,176
25.256198
91
py
null
coax-main/doc/examples/linear_regression/haiku.py
import jax import jax.numpy as jnp import haiku as hk from sklearn.datasets import make_regression from sklearn.model_selection import train_test_split # create our dataset X, y = make_regression(n_features=3) X, X_test, y, y_test = train_test_split(X, y) # params are defined *implicitly* in haiku def forward(X): ...
1,062
20.693878
76
py
null
coax-main/doc/examples/linear_regression/jax.py
import jax import jax.numpy as jnp from sklearn.datasets import make_regression from sklearn.model_selection import train_test_split # create our dataset X, y = make_regression(n_features=3) X, X_test, y, y_test = train_test_split(X, y) # model weights params = { 'w': jnp.zeros(X.shape[1:]), 'b': 0. } def...
797
18
65
py
null
coax-main/doc/examples/pendulum/ddpg.py
import gymnasium import jax import coax import haiku as hk import jax.numpy as jnp from numpy import prod import optax # the name of this script name = 'ddpg' # the Pendulum MDP env = gymnasium.make('Pendulum-v1', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorboard_dir=f"./data/tens...
2,903
26.923077
94
py
null
coax-main/doc/examples/pendulum/dsac.py
import gymnasium import jax import coax import haiku as hk import jax.numpy as jnp from numpy import prod import optax # the name of this script name = 'dsac' # the Pendulum MDP env = gymnasium.make('Pendulum-v1', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorboard_dir=f"./data/tens...
5,106
34.713287
95
py
null
coax-main/doc/examples/pendulum/ppo.py
import gymnasium import jax import jax.numpy as jnp import coax import haiku as hk from numpy import prod import optax # the name of this script name = 'ppo' # the Pendulum MDP env = gymnasium.make('Pendulum-v1', render_mode='rgb_array') env = coax.wrappers.TrainMonitor(env, name=name, tensorboard_dir=f"./data/tenso...
2,956
26.896226
97
py