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
GNOT
GNOT-master/readme.md
# GNOT: General Neural Operator Transformer (ICML 2023) Code for [GNOT: A General Neural Operator Transformer for Operator Learning](https://arxiv.org/abs/2302.14376), accepted at International Conference on Machine Learning (ICML 2023). - GNOT is a flexible Transformer with linear complexity attention for learning o...
4,815
38.154472
406
md
GNOT
GNOT-master/train.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import sys import os sys.path.append('../..') sys.path.append('..') import re import time import pickle import numpy as np import torch import torch.nn as nn from torch.optim.lr_scheduler import OneCycleLR, StepLR, LambdaLR from torch.utils.tensorboard import SummaryWrite...
10,040
31.079872
182
py
GNOT
GNOT-master/utils.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import os import torch import numpy as np import operator import matplotlib.pyplot as plt import torch import numpy as np import torch.special as ts from scipy import interpolate from functools import reduce def get_seed(s, printout=True, cudnn=True): # rd.seed(s) ...
17,709
34.562249
118
py
GNOT
GNOT-master/visualize_result.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import pickle import torch import numpy as np import torch.nn as nn import dgl import matplotlib.pyplot as plt from dgl.dataloading import GraphDataLoader from torch.utils.data.sampler import SubsetRandomSampler from utils import get_seed, get_num_params from args import ge...
2,452
25.095745
101
py
GNOT
GNOT-master/data_generation/__init__.py
#!/usr/bin/env python #-*- coding:utf-8 _*-
46
14.666667
23
py
GNOT
GNOT-master/models/__init__.py
#!/usr/bin/env python #-*- coding:utf-8 _*-
46
14.666667
23
py
GNOT
GNOT-master/models/cgpt.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import math import numpy as np import torch import torch.nn as nn import dgl from einops import repeat, rearrange from torch.nn import functional as F from torch.nn import GELU, ReLU, Tanh, Sigmoid from torch.nn.utils.rnn import pad_sequence from utils import MultipleTensor...
17,097
37.770975
190
py
GNOT
GNOT-master/models/mgpt.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import math import numpy as np import torch import torch.nn as nn import dgl from einops import repeat, rearrange from torch.nn import functional as F from torch.nn import GELU, ReLU, Tanh, Sigmoid from torch.nn.utils.rnn import pad_sequence from models.mlp import MLP c...
13,659
37.696884
246
py
GNOT
GNOT-master/models/mlp.py
import torch.nn as nn import torch.nn.functional as F import dgl ACTIVATION = {'gelu':nn.GELU(),'tanh':nn.Tanh(),'sigmoid':nn.Sigmoid(),'relu':nn.ReLU(),'leaky_relu':nn.LeakyReLU(0.1),'softplus':nn.Softplus(),'ELU':nn.ELU()} ''' A simple MLP class, includes at least 2 layers and n hidden layers ''' class MLP(nn....
1,270
30.775
159
py
GNOT
GNOT-master/models/mmgpt.py
#!/usr/bin/env python #-*- coding:utf-8 _*- import math import numpy as np import torch import torch.nn as nn import dgl from einops import repeat, rearrange from torch.nn import functional as F from torch.nn import GELU, ReLU, Tanh, Sigmoid from torch.nn.utils.rnn import pad_sequence from utils import MultipleTensors...
12,578
36.4375
214
py
GNOT
GNOT-master/models/optimizer.py
import math import torch from torch import Tensor from typing import List, Optional from torch.optim.optimizer import Optimizer def adam(params: List[Tensor], grads: List[Tensor], exp_avgs: List[Tensor], exp_avg_sqs: List[Tensor], max_exp_avg_sqs: List[Tensor], state_step...
12,976
37.853293
120
py
GNOT
GNOT-master/resources/__init__.py
#!/usr/bin/env python #-*- coding:utf-8 _*-
46
14.666667
23
py
F3Net
F3Net-master/README.md
## [F3Net: Fusion, Feedback and Focus for Salient Object Detection](https://arxiv.org/pdf/1911.11445.pdf) by Jun Wei, Shuhui Wang, Qingming Huang ## Introduction ![framework](./fig/framework.png)Most of existing salient object detection models have achieved great progress by aggregating multi-level features extracted ...
4,590
53.011765
1,872
md
F3Net
F3Net-master/eval/Emeasure.m
function [score]= Emeasure(FM,GT) % Emeasure Compute the Enhanced Alignment measure (as proposed in "Enhanced-alignment % Measure for Binary Foreground Map Evaluation" [Deng-Ping Fan et. al - IJCAI'18 oral paper]) % Usage: % score = Emeasure(FM,GT) % Input: % FM - Binary foreground map. Type: double. % GT - Binary ...
2,267
29.24
118
m
F3Net
F3Net-master/eval/Fmeasure.m
%% function [PreFtem, RecallFtem, FmeasureF] = Fmeasure(sMap, gtMap, gtsize) sumLabel = 2* mean(sMap(:)); if (sumLabel > 1) sumLabel = 1; end Label3 = zeros( gtsize ); Label3(sMap>=sumLabel ) = 1; NumRec = length( find( Label3==1 ) ); LabelAnd = Label3 & gtMap; NumAnd = length( find ( LabelAnd==1 ) ); num_ob...
564
19.178571
73
m
F3Net
F3Net-master/eval/MAE.m
function mae = MAE(smap, gtImg) % Code Author: Wangjiang Zhu % Email: wangjiang88119@gmail.com % Date: 3/24/2014 if size(smap, 1) ~= size(gtImg, 1) || size(smap, 2) ~= size(gtImg, 2) error('Saliency map and gt Image have different sizes!\n'); end if ~islogical(gtImg) gtImg = gtImg(:,:,1) > 128; end fgPixels =...
457
27.625
69
m
F3Net
F3Net-master/eval/PRCurve.m
function [precision, recall] = PRCurve(smapImg, gtImg) % Code Author: Wangjiang Zhu % Email: wangjiang88119@gmail.com % Date: 3/24/2014 if ~islogical(gtImg) gtImg = gtImg(:,:,1) > 128; end if any(size(smapImg) ~= size(gtImg)) error('saliency map and ground truth mask have different size'); end gtPxlNum = sum(...
874
26.34375
110
m
F3Net
F3Net-master/eval/S_object.m
function Q = S_object(prediction,GT) % S_object Computes the object similarity between foreground maps and ground % truth(as proposed in "Structure-measure:A new way to evaluate foreground % maps" [Deng-Ping Fan et. al - ICCV 2017]) % Usage: % Q = S_object(prediction,GT) % Input: % prediction - Binary/Non binary f...
1,667
27.758621
79
m
F3Net
F3Net-master/eval/S_region.m
function Q = S_region(prediction,GT) % S_region computes the region similarity between the foreground map and % ground truth(as proposed in "Structure-measure:A new way to evaluate % foreground maps" [Deng-Ping Fan et. al - ICCV 2017]) % Usage: % Q = S_region(prediction,GT) % Input: % prediction - Binary/Non binary...
3,681
24.929577
89
m
F3Net
F3Net-master/eval/Smeasure.m
function Q = Smeasure(prediction,GT) % Smeasure computes the similarity between the foreground map and % ground truth(as proposed in "Structure-measure: A new way to evaluate % foreground maps" [Deng-Ping Fan et. al - ICCV 2017]) % Usage: % Q = Smeasure(prediction,GT) % Input: % prediction - Binary/Non binary foreg...
1,222
30.358974
75
m
F3Net
F3Net-master/eval/main.m
algorithms = { %'C2SNet'; %'BMPM'; %'DGRL'; %'R3Net'; %'RAS'; %'PiCA-R'; %'PAGE'; %'TDBU'; %'BASNet'; %'CPD-R'; %'PoolNet'; %'AFNet'; 'F3Net' }; datasets = { 'ECSSD'; 'PASCAL-S'; 'DUTS'; 'HKU-I...
3,979
35.851852
102
m
F3Net
F3Net-master/eval/wFmeasure.m
function [Q]= wFmeasure(FG,GT) % wFmeasure Compute the Weighted F-beta measure (as proposed in "How to Evaluate Foreground Maps?" [Margolin et. al - CVPR'14]) % Usage: % Q = FbW(FG,GT) % Input: % FG - Binary/Non binary foreground map with values in the range [0 1]. Type: double. % GT - Binary ground truth. Type: lo...
1,423
25.37037
127
m
F3Net
F3Net-master/src/dataset.py
#!/usr/bin/python3 #coding=utf-8 import os import cv2 import torch import numpy as np from torch.utils.data import Dataset ########################### Data Augmentation ########################### class Normalize(object): def __init__(self, mean, std): self.mean = mean self.std = std de...
4,497
32.819549
96
py
F3Net
F3Net-master/src/net.py
#!/usr/bin/python3 #coding=utf-8 import numpy as np import matplotlib.pyplot as plt import torch import torch.nn as nn import torch.nn.functional as F def weight_init(module): for n, m in module.named_children(): print('initialize: '+n) if isinstance(m, nn.Conv2d): nn.init.kaiming_norm...
8,656
43.623711
141
py
F3Net
F3Net-master/src/test.py
#!/usr/bin/python3 #coding=utf-8 import os import sys sys.path.insert(0, '../') sys.dont_write_bytecode = True import cv2 import numpy as np import matplotlib.pyplot as plt plt.ion() import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader from tensorboardX import Su...
2,319
32.142857
109
py
F3Net
F3Net-master/src/train.py
#!/usr/bin/python3 #coding=utf-8 import sys import datetime sys.path.insert(0, '../') sys.dont_write_bytecode = True import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import DataLoader from tensorboardX import SummaryWriter import dataset from net import F3Net from apex import ...
3,380
38.313953
205
py
null
coax-main/.readthedocs.yml
version: 2 build: image: latest python: version: 3.8 install: - method: pip path: . extra_requirements: - doc system_packages: true sphinx: builder: html configuration: doc/conf.py
210
10.722222
28
yml
null
coax-main/STATUS.md
# Development Status In this file we list the current status of the tests written (and passed). | | docs | unit tests | FrozenLake | CartPole | Pong | Pendulum | LunarLander | Ant | |-----------------|:----:|:----------:|:----------:|:--------:|:----:|:--------:|:-----------:|:---:| | ValueTD ...
1,324
68.736842
101
md
null
coax-main/setup.py
#!/usr/bin/env python3 import re import os import setuptools from collections import namedtuple PROJECTDIR = os.path.dirname(__file__) RE_VERSION = re.compile( r'^__version__ \= \'(?P<version>(?P<majorminor>\d+\.\d+)\.\d+(?:\w+\d+)?)\'$', re.MULTILINE) DEV_STATUS = { '0.1': 'Development Status :: 1 - Planning'...
3,174
34.277778
99
py
null
coax-main/upgrade_requirements.py
""" To update the requirements files, first do a pip freeze in google colab and then past the output in requirements.colab.txt After that, just run this script from the project root (where this script is located). """ import re from sys import stderr from packaging.version import parse as _parse import pandas as pd...
1,870
30.183333
100
py
null
coax-main/.azure/docs.yml
# https://docs.microsoft.com/azure/devops/pipelines/languages/python trigger: - main pool: vmImage: 'ubuntu-latest' variables: python.version: '3.8' TF_CPP_MIN_LOG_LEVEL: 3 # tell XLA to be quiet JAX_PLATFORM_NAME: cpu steps: - task: UsePythonVersion@0 inputs: versionSpec: '$(python.version)' displ...
1,259
22.333333
68
yml
null
coax-main/.azure/tests.yml
# https://docs.microsoft.com/azure/devops/pipelines/languages/python trigger: - main pool: vmImage: 'ubuntu-latest' variables: TF_CPP_MIN_LOG_LEVEL: 3 # tell XLA to be quiet strategy: matrix: Python37_cpu: python.version: '3.7' JAX_PLATFORM_NAME: cpu Python38_cpu: python.version: '3...
1,583
25.4
80
yml
null
coax-main/.github/ISSUE_TEMPLATE/bug_report.md
--- name: Bug report about: Create a report to help us improve title: '' labels: 'triage' assignees: '' --- **Describe the bug** <!-- A clear and concise description of what the bug is. --> **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> **To Reproduce** Colab noteboo...
958
26.4
101
md
null
coax-main/.github/ISSUE_TEMPLATE/feature_request.md
--- name: Feature request about: Suggest an idea for this project title: '' labels: 'enhancement' assignees: '' --- **Is your feature request related to a problem? Please describe.** <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> **Describe the solution you'd li...
642
29.619048
101
md
null
coax-main/.github/ISSUE_TEMPLATE/question.md
--- name: Question about: Ask a question about this project title: '' labels: 'question' assignees: '' --- **What's your question?** <!-- Please explain the context of your question. -->
191
12.714286
53
md
null
coax-main/.github/workflows/release.yml
name: release on: push: tags: - 'v*' jobs: test: name: Run tests runs-on: ${{ matrix.runs-on }} strategy: matrix: runs-on: [ubuntu-latest, macos-latest] python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{...
2,603
28.931034
87
yml
null
coax-main/.github/workflows/tests.yml
name: tests on: push: branches: - main pull_request: branches: - main jobs: test: name: Run tests runs-on: ${{ matrix.runs-on }} strategy: matrix: runs-on: [ubuntu-latest, macos-latest] python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions...
1,510
30.479167
87
yml
null
coax-main/coax/__init__.py
__version__ = '0.1.13' # fall back to legacy gym if gymnasium is unavailable try: import gymnasium as _gymnasium except ImportError: import sys import warnings warnings.warn("Cannot import 'gymnasium'; attempting to fall back to legacy 'gym'.") import gym as _gymnasium # Don't catch ImportError he...
2,853
26.180952
88
py
null
coax-main/coax/typing.py
from typing import TypeVar, Union, Sequence, Callable, Tuple __all__ = ( 'Batch', 'SpaceElement', 'Observation', 'Action' ) Batch = Sequence # annotate batched quantities Observation = TypeVar('Observation') # a state observation Action = TypeVar('Action') ...
573
23.956522
80
py
null
coax-main/coax/_base/__init__.py
0
0
0
py
null
coax-main/coax/_base/errors.py
class CoaxError(Exception): pass class SpaceError(CoaxError): pass class ActionSpaceError(SpaceError): pass class DistributionError(CoaxError): pass class EpisodeDoneError(CoaxError): pass class InconsistentCacheInputError(CoaxError): pass class InsufficientCacheError(CoaxError): ...
662
10.839286
45
py
null
coax-main/coax/_base/test_case.py
import gc import unittest from collections import namedtuple from contextlib import AbstractContextManager from resource import getrusage, RUSAGE_SELF from functools import partial import gymnasium import jax import jax.numpy as jnp import numpy as onp import haiku as hk __all__ = ( 'DiscreteEnv', 'BoxEnv', ...
13,055
36.517241
95
py
null
coax-main/coax/_base/mixins/__init__.py
from ._add_orig_to_info import AddOrigToInfoDictMixin from ._copy import CopyMixin from ._logger import LoggerMixin from ._random_state import RandomStateMixin __all__ = ( 'AddOrigToInfoDictMixin', 'CopyMixin', 'LoggerMixin', 'RandomStateMixin', )
266
19.538462
53
py
null
coax-main/coax/_base/mixins/_add_orig_to_info.py
from typing import Mapping class AddOrigToInfoDictMixin: def _add_s_orig_to_info_dict(self, info): if not isinstance(info, Mapping): assert info is None, "unexpected type for 'info' Mapping" info = {} if 's_orig' in info: info['s_orig'].append(self._s_orig) ...
895
27.903226
69
py
null
coax-main/coax/_base/mixins/_copy.py
from copy import deepcopy, copy class CopyMixin: def copy(self, deep=False): r""" Create a copy of the current instance. Parameters ---------- deep : bool, optional Whether the copy should be a deep copy. Returns ------- copy ...
429
16.916667
53
py
null
coax-main/coax/_base/mixins/_logger.py
import logging class LoggerMixin: @property def logger(self): return logging.getLogger(self.__class__.__name__)
130
15.375
57
py
null
coax-main/coax/_base/mixins/_random_state.py
import numpy as onp import jax class RandomStateMixin: @property def random_seed(self): return self._random_seed @random_seed.setter def random_seed(self, new_random_seed): if new_random_seed is None: new_random_seed = onp.random.randint(2147483647) self._random_se...
526
24.095238
66
py
null
coax-main/coax/_core/__init__.py
0
0
0
py
null
coax-main/coax/_core/base_func.py
from abc import ABC, abstractmethod from typing import Any, Tuple, NamedTuple import jax import haiku as hk from gymnasium.spaces import Space from ..typing import Batch, Observation, Action from ..utils import pretty_repr, jit from .._base.mixins import RandomStateMixin, CopyMixin class Inputs(NamedTuple): arg...
5,555
31.115607
100
py
null
coax-main/coax/_core/base_stochastic_func_type1.py
from inspect import signature from collections import namedtuple import jax import jax.numpy as jnp import numpy as onp import haiku as hk from gymnasium.spaces import Space, Discrete from ..utils import safe_sample, batch_to_single, jit from .base_func import BaseFunc, ExampleData, Inputs, ArgsType1, ArgsType2, Mode...
19,163
41.39823
100
py
null
coax-main/coax/_core/base_stochastic_func_type2.py
from inspect import signature from collections import namedtuple import jax import jax.numpy as jnp import numpy as onp import haiku as hk from gymnasium.spaces import Space from ..utils import safe_sample, batch_to_single, jit from .base_func import BaseFunc, ExampleData, Inputs, ArgsType2 __all__ = ( 'BaseSto...
7,645
35.583732
98
py
null
coax-main/coax/_core/policy.py
from ..utils import default_preprocessor from ..proba_dists import ProbaDist from .base_stochastic_func_type2 import BaseStochasticFuncType2 class Policy(BaseStochasticFuncType2): r""" A parametrized policy :math:`\pi_\theta(a|s)`. Parameters ---------- func : function A Haiku-style fun...
4,373
25.509091
100
py
null
coax-main/coax/_core/policy_test.py
from functools import partial from collections import namedtuple import gymnasium import jax import jax.numpy as jnp import numpy as onp import haiku as hk from .._base.test_case import TestCase from ..utils import safe_sample from .policy import Policy discrete = gymnasium.spaces.Discrete(7) boxspace = gymnasium.s...
5,038
31.934641
80
py
null
coax-main/coax/_core/q.py
from inspect import signature from collections import namedtuple import jax import jax.numpy as jnp import numpy as onp import haiku as hk from gymnasium.spaces import Space, Discrete from ..utils import safe_sample, default_preprocessor from ..value_transforms import ValueTransform from .base_func import BaseFunc, E...
10,806
35.265101
100
py
null
coax-main/coax/_core/q_test.py
from functools import partial import jax import jax.numpy as jnp import numpy as onp import haiku as hk from .._base.test_case import TestCase, DiscreteEnv, BoxEnv from ..utils import safe_sample from .q import Q env_discrete = DiscreteEnv(random_seed=13) env_boxspace = BoxEnv(random_seed=17) def func_type1(S, A,...
7,736
31.783898
97
py
null
coax-main/coax/_core/random_policy.py
import gymnasium import jax.numpy as jnp import numpy as onp from ..utils import docstring from .policy import Policy __all__ = ( 'RandomPolicy', ) class RandomPolicy: r""" A simple random policy. Parameters ---------- env : gymnasium.Env The gymnasium-style environment. This is ...
2,336
29.75
95
py
null
coax-main/coax/_core/random_policy_test.py
from functools import partial import gymnasium import jax import haiku as hk import numpy as onp from .._base.test_case import TestCase from .random_policy import RandomPolicy env = gymnasium.make('FrozenLakeNonSlippery-v0') def func_type2(S, is_training): batch_norm = hk.BatchNorm(False, False, 0.99) seq...
1,627
26.59322
81
py
null
coax-main/coax/_core/reward_function.py
from .q import Q __all__ = ( 'RewardFunction', ) class RewardFunction(Q): r""" A deterministic reward function :math:`r_\theta(s,a)`. Parameters ---------- func : function A Haiku-style function that specifies the forward pass. The function signature must be the same as th...
1,889
29.483871
99
py
null
coax-main/coax/_core/stochastic_q.py
from gymnasium.spaces import Box from ..utils import default_preprocessor from ..proba_dists import DiscretizedIntervalDist, EmpiricalQuantileDist from ..value_transforms import ValueTransform from .base_stochastic_func_type1 import BaseStochasticFuncType1 __all__ = ( 'StochasticQ', ) class StochasticQ(BaseSto...
9,039
33.503817
100
py
null
coax-main/coax/_core/stochastic_q_test.py
from functools import partial from collections import namedtuple import jax import jax.numpy as jnp import haiku as hk from gymnasium.spaces import Discrete, Box from .._base.test_case import TestCase from ..utils import safe_sample, quantile_cos_embedding, quantiles, quantiles_uniform from .stochastic_q import Stoch...
14,291
36.909814
100
py
null
coax-main/coax/_core/stochastic_reward_function.py
from .stochastic_q import StochasticQ __all__ = ( 'StochasticRewardFunction', ) class StochasticRewardFunction(StochasticQ): r""" A stochastic reward function :math:`p_\theta(r|s,a)`. Parameters ---------- func : function A Haiku-style function that specifies the forward pass. ...
2,642
33.776316
100
py
null
coax-main/coax/_core/stochastic_transition_model.py
from ..utils import default_preprocessor from ..proba_dists import ProbaDist from .base_stochastic_func_type1 import BaseStochasticFuncType1 __all__ = ( 'StochasticTransitionModel', ) class StochasticTransitionModel(BaseStochasticFuncType1): r""" A stochastic transition model :math:`p_\theta(s'|s,a)`. ...
6,627
31.174757
100
py
null
coax-main/coax/_core/stochastic_transition_model_test.py
from functools import partial from collections import namedtuple import gymnasium import jax import jax.numpy as jnp import numpy as onp import haiku as hk from .._base.test_case import TestCase from ..utils import safe_sample from .stochastic_transition_model import StochasticTransitionModel discrete = gymnasium.s...
14,579
37.067885
100
py
null
coax-main/coax/_core/stochastic_v.py
from gymnasium.spaces import Box from ..utils import default_preprocessor from ..proba_dists import DiscretizedIntervalDist from ..value_transforms import ValueTransform from .base_stochastic_func_type2 import BaseStochasticFuncType2 __all__ = ( 'StochasticV', ) class StochasticV(BaseStochasticFuncType2): ...
6,909
30.409091
100
py
null
coax-main/coax/_core/stochastic_v_test.py
from functools import partial from collections import namedtuple import jax import jax.numpy as jnp import haiku as hk from gymnasium.spaces import Discrete, Box from .._base.test_case import TestCase from ..utils import safe_sample from .stochastic_v import StochasticV discrete = Discrete(7) boxspace = Box(low=0, h...
4,708
34.674242
100
py
null
coax-main/coax/_core/successor_state_q.py
import warnings import jax import haiku as hk from .._core.q import Q from .._core.base_stochastic_func_type1 import BaseStochasticFuncType1 from ..utils import ( check_preprocessors, is_vfunction, is_reward_function, is_transition_model, is_stochastic, jit) __all__ = ( 'SuccessorStateQ', ) class Successo...
9,697
38.745902
100
py
null
coax-main/coax/_core/transition_model.py
from inspect import signature from collections import namedtuple import jax import jax.numpy as jnp import numpy as onp import haiku as hk from gymnasium.spaces import Space, Discrete from ..utils import safe_sample, batch_to_single, default_preprocessor from ..proba_dists import ProbaDist from .base_func import Base...
12,966
39.395639
100
py
null
coax-main/coax/_core/transition_model_test.py
from functools import partial from collections import namedtuple import gymnasium import jax import jax.numpy as jnp import numpy as onp import haiku as hk from .._base.test_case import TestCase from ..utils import safe_sample from .transition_model import TransitionModel discrete = gymnasium.spaces.Discrete(7) box...
8,653
35.982906
100
py
null
coax-main/coax/_core/v.py
from inspect import signature from collections import namedtuple import jax import jax.numpy as jnp import numpy as onp import haiku as hk from gymnasium.spaces import Space from ..utils import safe_sample, default_preprocessor from ..value_transforms import ValueTransform from .base_func import BaseFunc, ExampleData...
5,528
33.12963
100
py
null
coax-main/coax/_core/v_test.py
from functools import partial import jax import jax.numpy as jnp import haiku as hk from .._base.test_case import TestCase from ..utils import get_transition_batch, safe_sample from .v import V def func(S, is_training): rng1, rng2, rng3 = hk.next_rng_keys(3) rate = 0.25 if is_training else 0. batch_norm...
3,296
34.451613
97
py
null
coax-main/coax/_core/value_based_policy.py
import gymnasium import jax import jax.numpy as jnp import haiku as hk import chex from ..utils import docstring, is_qfunction, is_stochastic, jit from ..proba_dists import CategoricalDist from .base_stochastic_func_type2 import StochasticFuncType2Mixin from .q import Q __all__ = ( 'EpsilonGreedy', 'Boltzman...
7,757
27.417582
100
py
null
coax-main/coax/_core/value_based_policy_test.py
from functools import partial import gymnasium import jax import haiku as hk import numpy as onp from .._base.test_case import TestCase from .q import Q from .value_based_policy import EpsilonGreedy, BoltzmannPolicy env = gymnasium.make('FrozenLakeNonSlippery-v0') def func_type2(S, is_training): batch_norm = ...
3,106
30.383838
98
py
null
coax-main/coax/_core/worker.py
import time import inspect from abc import ABC, abstractmethod from typing import Optional import gymnasium from jax.lib.xla_bridge import get_backend from ..typing import Policy from ..wrappers import TrainMonitor from ..reward_tracing._base import BaseRewardTracer from ..experience_replay._base import BaseReplayBuf...
11,753
32.487179
100
py
null
coax-main/coax/envs/__init__.py
r""" Environments ============ .. autosummary:: :nosignatures: coax.envs.ConnectFourEnv ---- This is a collection of environments currently not included in `Gymnasium <https://gymnasium.farama.org/>`_. Object Reference ---------------- .. autoclass:: coax.envs.ConnectFourEnv """ from ._connect_four imp...
377
12.034483
62
py
null
coax-main/coax/envs/_connect_four.py
from gymnasium import Env from gymnasium.spaces import Discrete, MultiDiscrete import numpy as np from .._base.errors import UnavailableActionError, EpisodeDoneError __all__ = ( 'ConnectFourEnv', ) class ConnectFourEnv(Env): r""" An adversarial environment for playing the `Connect-Four game <https:...
10,349
31.961783
79
py
null
coax-main/coax/experience_replay/__init__.py
r""" Experience Replay ================= .. autosummary:: :nosignatures: coax.experience_replay.SimpleReplayBuffer coax.experience_replay.PrioritizedReplayBuffer ---- This is where we keep our experience-replay buffer classes. Some examples of agents that use a replay buffer are: * :doc:`/examples/stub...
785
19.153846
96
py
null
coax-main/coax/experience_replay/_base.py
from abc import ABC, abstractmethod __all__ = ( 'BaseReplayBuffer', ) class BaseReplayBuffer(ABC): @property @abstractmethod def capacity(self): pass @abstractmethod def add(self, transition_batch): pass @abstractmethod def sample(self, batch_size=32): pass...
549
13.102564
36
py
null
coax-main/coax/experience_replay/_prioritized.py
import jax import numpy as onp import chex from ..reward_tracing import TransitionBatch from ..utils import SumTree from ._base import BaseReplayBuffer __all__ = ( 'PrioritizedReplayBuffer', ) class PrioritizedReplayBuffer(BaseReplayBuffer): r""" A simple ring buffer for experience replay, with priori...
7,832
32.909091
100
py
null
coax-main/coax/experience_replay/_prioritized_test.py
from copy import deepcopy import gymnasium import pytest import numpy as onp from ..utils import get_transition_batch from ._simple import SimpleReplayBuffer from ._prioritized import PrioritizedReplayBuffer @pytest.mark.parametrize('n', [2, 4]) # 2 * batch_size < capacity, 4 * batch_size > capacity def test_consi...
4,654
36.540323
99
py
null
coax-main/coax/experience_replay/_simple.py
import random import jax import numpy as onp from ..reward_tracing import TransitionBatch from ._base import BaseReplayBuffer __all__ = ( 'SimpleReplayBuffer', ) class SimpleReplayBuffer(BaseReplayBuffer): r""" A simple ring buffer for experience replay. Parameters ---------- capacity : ...
2,588
25.151515
100
py
null
coax-main/coax/model_updaters/__init__.py
r""" Model Updaters ============== .. autosummary:: :nosignatures: coax.model_updaters.ModelUpdater ---- This is a collection of objects that are used to update dynamics models, i.e. transition models and reward functions. Object Reference ---------------- .. autoclass:: coax.model_updaters.ModelUpdater ...
472
14.258065
99
py
null
coax-main/coax/model_updaters/_model_updater.py
import jax import jax.numpy as jnp import haiku as hk import optax from ..utils import ( get_grads_diagnostics, is_stochastic, is_reward_function, is_transition_model, jit) from ..value_losses import huber from ..regularizers import Regularizer __all__ = ( 'ModelUpdater', ) class ModelUpdater: r""" ...
8,272
35.606195
100
py
null
coax-main/coax/model_updaters/_model_updater_test.py
from copy import deepcopy from optax import sgd from .._base.test_case import TestCase from .._core.stochastic_transition_model import StochasticTransitionModel from ..utils import get_transition_batch from ..regularizers import EntropyRegularizer from ._model_updater import ModelUpdater class TestModelUpdater(Test...
3,182
37.349398
98
py
null
coax-main/coax/policy_objectives/__init__.py
r""" Policy Objectives ================= .. autosummary:: :nosignatures: coax.policy_objectives.VanillaPG coax.policy_objectives.PPOClip coax.policy_objectives.DeterministicPG coax.policy_objectives.SoftPG ---- This is a collection of policy objectives that can be used in policy-gradient method...
873
18.422222
77
py
null
coax-main/coax/policy_objectives/_base.py
import warnings import jax import jax.numpy as jnp import optax import haiku as hk from .._core.policy import Policy from ..utils import get_grads_diagnostics, jit from ..regularizers import Regularizer class PolicyObjective: r""" Abstract base class for policy objectives. To see a concrete example, have a...
7,993
35.009009
100
py
null
coax-main/coax/policy_objectives/_deterministic_pg.py
import warnings import jax.numpy as jnp import haiku as hk import chex from ..utils import check_preprocessors, is_qfunction, is_stochastic from ._base import PolicyObjective class DeterministicPG(PolicyObjective): r""" A deterministic policy-gradient objective, a.k.a. DDPG-style objective. See :doc:`sp...
5,813
32.606936
98
py
null
coax-main/coax/policy_objectives/_deterministic_pg_test.py
from copy import deepcopy import jax.numpy as jnp from optax import sgd from .._base.test_case import TestCase from .._core.policy import Policy from .._core.q import Q from ..utils import tree_ravel from ._deterministic_pg import DeterministicPG class TestDeterministicPG(TestCase): def test_update_discrete(se...
1,802
31.196429
96
py
null
coax-main/coax/policy_objectives/_ppo_clip.py
import jax.numpy as jnp import haiku as hk import chex from ._base import PolicyObjective class PPOClip(PolicyObjective): r""" PPO-clip policy objective. .. math:: J(\theta; s,a)\ =\ \min\Big( \rho_\theta\,\mathcal{A}(s,a)\,,\ \bar{\rho}_\theta\,\mathcal{A}(s,a)\Big) ...
2,898
31.573034
92
py
null
coax-main/coax/policy_objectives/_ppo_clip_test.py
from copy import deepcopy import jax.numpy as jnp from optax import sgd from .._base.test_case import TestCase from .._core.policy import Policy from ..utils import tree_ravel from ._ppo_clip import PPOClip class TestPPOClip(TestCase): def test_update_discrete(self): env = self.env_discrete fun...
1,603
29.264151
80
py
null
coax-main/coax/policy_objectives/_soft_pg.py
import jax.numpy as jnp import haiku as hk import chex from ._base import PolicyObjective from ..utils import is_qfunction, is_stochastic class SoftPG(PolicyObjective): def __init__(self, pi, q_targ_list, optimizer=None, regularizer=None): super().__init__(pi, optimizer=optimizer, regularizer=regulariz...
4,604
34.423077
99
py
null
coax-main/coax/policy_objectives/_soft_pg_test.py
# ------------------------------------------------------------------------------------------------ # # MIT License # # # # Copyright (c) 2...
4,226
43.968085
100
py
null
coax-main/coax/policy_objectives/_vanilla_pg.py
import jax.numpy as jnp import haiku as hk import chex from ._base import PolicyObjective class VanillaPG(PolicyObjective): r""" A vanilla policy-gradient objective, a.k.a. REINFORCE-style objective. .. math:: J(\theta; s,a)\ =\ \mathcal{A}(s,a)\,\log\pi_\theta(a|s) This objective has the ...
1,774
29.603448
85
py
null
coax-main/coax/policy_objectives/_vanilla_pg_test.py
from copy import deepcopy import jax.numpy as jnp from optax import sgd from .._base.test_case import TestCase from .._core.policy import Policy from ..utils import tree_ravel from ..regularizers import EntropyRegularizer, KLDivRegularizer from ._vanilla_pg import VanillaPG class TestVanillaPG(TestCase): def t...
4,663
32.797101
80
py
null
coax-main/coax/proba_dists/__init__.py
r""" .. autosummary:: :nosignatures: coax.proba_dists.ProbaDist coax.proba_dists.CategoricalDist coax.proba_dists.NormalDist coax.proba_dists.DiscretizedIntervalDist coax.proba_dists.EmpiricalQuantileDist coax.proba_dists.SquashedNormalDist ----- Probability Distributions ================...
1,198
23.469388
97
py
null
coax-main/coax/proba_dists/_base.py
from abc import ABC, abstractmethod import gymnasium import jax from ..utils import batch_to_single class BaseProbaDist(ABC): r""" Abstract base class for probability distributions. Check out :class:`coax.proba_dists.CategoricalDist` for a specific example. """ __slots__ = ( '_space', ...
8,223
23.99696
100
py
null
coax-main/coax/proba_dists/_categorical.py
import jax import jax.numpy as jnp from gymnasium.spaces import Discrete from ..utils import argmax, jit from ._base import BaseProbaDist __all__ = ( 'CategoricalDist', ) class CategoricalDist(BaseProbaDist): r""" A differentiable categorical distribution. The input ``dist_params`` to each of the...
10,618
30.698507
100
py
null
coax-main/coax/proba_dists/_composite.py
from enum import Enum import gymnasium import numpy as onp import haiku as hk import jax from ..utils import jit from ._base import BaseProbaDist from ._categorical import CategoricalDist from ._normal import NormalDist __all__ = ( 'ProbaDist', ) class StructureType(Enum): LEAF = 0 LIST = 1 DICT =...
11,802
40.125436
100
py
null
coax-main/coax/proba_dists/_composite_test.py
import gymnasium import jax import jax.numpy as jnp import haiku as hk from .._base.test_case import TestCase from ._normal import NormalDist from ._categorical import CategoricalDist from ._composite import ProbaDist, StructureType discrete = gymnasium.spaces.Discrete(7) box = gymnasium.spaces.Box(low=0, high=1, sha...
12,738
46.356877
97
py
null
coax-main/coax/proba_dists/_discretized_interval.py
import jax import jax.numpy as jnp import numpy as onp import chex from gymnasium.spaces import Box, Discrete from ..utils import isscalar, jit from ._categorical import CategoricalDist __all__ = ( 'DiscretizedIntervalDist', ) class DiscretizedIntervalDist(CategoricalDist): r""" A categorical distribu...
6,166
37.54375
98
py
null
coax-main/coax/proba_dists/_empirical_quantile.py
import chex import jax import jax.numpy as jnp from gymnasium.spaces import Box from ..utils import jit, isscalar from ._base import BaseProbaDist __all__ = ( 'EmpiricalQuantileDist', ) class EmpiricalQuantileDist(BaseProbaDist): def __init__(self, num_quantiles): self.num_quantiles = num_quantile...
2,964
32.693182
89
py