repo_full_name
stringlengths
6
93
repo_url
stringlengths
25
112
repo_api_url
stringclasses
28 values
owner
stringclasses
28 values
repo_name
stringclasses
28 values
description
stringclasses
28 values
stars
int64
617
98.8k
forks
int64
31
355
watchers
int64
990
999
license
stringclasses
2 values
default_branch
stringclasses
2 values
repo_created_at
timestamp[s]date
2012-07-24 23:12:50
2025-06-16 08:07:28
repo_updated_at
timestamp[s]date
2026-02-23 15:23:15
2026-05-03 18:52:12
repo_topics
listlengths
0
13
repo_languages
unknown
is_fork
bool
1 class
open_issues
int64
3
104
file_path
stringlengths
3
208
file_name
stringclasses
509 values
file_extension
stringclasses
1 value
file_size_bytes
int64
101
84k
file_url
stringclasses
627 values
file_raw_url
stringclasses
627 values
file_sha
stringclasses
624 values
language
stringclasses
8 values
parsed_at
stringdate
2026-05-04 01:12:36
2026-05-04 19:41:55
text
stringlengths
100
102k
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_np_extractor.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.257408
import unittest import nltk import pytest from textblob.base import BaseNPExtractor from textblob.np_extractors import ConllExtractor from textblob.utils import filter_insignificant class TestConllExtractor(unittest.TestCase): def setUp(self): self.extractor = ConllExtractor() self.text = """ Py...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_parsers.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.278789
import unittest from textblob.en import parse as pattern_parse from textblob.parsers import PatternParser class TestPatternParser(unittest.TestCase): def setUp(self): self.parser = PatternParser() self.text = "And now for something completely different." def test_parse(self): assert ...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_decorators.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.343307
import unittest import pytest from textblob.decorators import requires_nltk_corpus from textblob.exceptions import MissingCorpusError class Tokenizer: @requires_nltk_corpus def tag(self, text): raise LookupError def test_decorator_raises_missing_corpus_exception(): t = Tokenizer() with pyt...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_sentiments.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.343937
import unittest import pytest from textblob.sentiments import ( CONTINUOUS, DISCRETE, NaiveBayesAnalyzer, PatternAnalyzer, ) class TestPatternSentiment(unittest.TestCase): def setUp(self): self.analyzer = PatternAnalyzer() def test_kind(self): assert self.analyzer.kind == CO...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_taggers.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.387765
import os import unittest import pytest import textblob.taggers from textblob.base import BaseTagger HERE = os.path.abspath(os.path.dirname(__file__)) AP_MODEL_LOC = os.path.join(HERE, "trontagger.pickle") class TestPatternTagger(unittest.TestCase): def setUp(self): self.text = "Simple is better than c...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_utils.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.789558
import os from unittest import TestCase from textblob.utils import is_filelike, lowerstrip, strip_punc HERE = os.path.abspath(os.path.dirname(__file__)) CSV_FILE = os.path.join(HERE, "data.csv") class UtilsTests(TestCase): def setUp(self): self.text = "this. Has. Punctuation?! " def test_strip_punc...
sloria/TextBlob
https://github.com/sloria/TextBlob
null
null
null
null
9,518
null
null
mit
null
null
null
null
null
null
null
tests/test_tokenizers.py
null
null
null
null
null
null
Python
2026-05-04T02:05:04.932749
import unittest import pytest from textblob.tokenizers import ( SentenceTokenizer, WordTokenizer, sent_tokenize, word_tokenize, ) def is_generator(obj): return hasattr(obj, "__next__") class TestWordTokenizer(unittest.TestCase): def setUp(self): self.tokenizer = WordTokenizer() ...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/_torch_specific.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.384366
""" Specialization of einops for torch. Unfortunately, torch's jit scripting mechanism isn't strong enough, and to have scripting supported at least for layers, a number of additional moves is needed. Design of main operations (dynamic resolution by lookup) is unlikely to be implemented by torch.jit.script, but torch...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/experimental/indexing.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.386073
""" This file contained some thoughts on indexing. These ideas were developed further in eindex (separate package). """
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/_einmix.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.387652
import string import warnings from typing import Any from einops import EinopsError from einops.einops import _product from einops.parsing import ParsedExpression, _ellipsis def _report_axes(axes: set, report_message: str): if len(axes) > 0: raise EinopsError(report_message.format(axes)) class _EinmixM...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/array_api.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.389060
from collections.abc import Sequence from types import ModuleType from typing import TYPE_CHECKING, Protocol, TypeAlias, TypeVar, cast from .einops import EinopsError, Reduction, _apply_recipe_array_api, _prepare_transformation_recipe from .packing import analyze_pattern, prod if TYPE_CHECKING: from typing_extens...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/_backends.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.390147
""" Backends in `einops` are organized to meet the following requirements - backends are not imported unless those are actually needed, because - backends may not be installed - importing all available backends will drive to significant memory footprint - backends may be present but installed with errors (b...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.391799
# imports can use EinopsError class # ruff: noqa: E402 __author__ = "Alex Rogozhnikov" __version__ = "0.9.0dev" class EinopsError(RuntimeError): """Runtime error thrown by einops""" pass # noqa: PIE790 __all__ = ["EinopsError", "asnumpy", "einsum", "pack", "parse_shape", "rearrange", "reduce", "repeat", ...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.392732
__author__ = "Alex Rogozhnikov" from typing import Any from einops import EinopsError from einops.einops import TransformRecipe, _apply_recipe, _prepare_recipes_for_all_dims, get_backend class RearrangeMixin: """ Rearrange layer behaves identically to einops.rearrange operation. :param pattern: str, re...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/einops.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.409823
import functools import itertools import string import typing from collections import OrderedDict from typing import Any, Protocol, TypeAlias, TypeVar, cast, overload from . import EinopsError from ._backends import get_backend from .parsing import AnonymousAxis, ParsedExpression, _ellipsis Tensor = TypeVar("Tensor")...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
docs/utils/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:07.443535
import numpy as np from IPython import get_ipython from IPython.display import display_html from PIL.Image import fromarray def display_np_arrays_as_images(): def np_to_png(a): if 2 <= len(a.shape) <= 3: return fromarray(np.array(np.clip(a, 0, 1) * 255, dtype="uint8"))._repr_png_() els...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/flax.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.003543
from dataclasses import field from typing import cast import flax.linen as nn import jax import jax.numpy as jnp from . import RearrangeMixin, ReduceMixin from ._einmix import _EinmixMixin __author__ = "Alex Rogozhnikov" class Reduce(nn.Module): pattern: str reduction: str sizes: dict = field(default_f...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/tensorflow.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.012661
""" Comment about tensorflow layers: unfortunately instructions on creation of TF layers change constantly, and changed way too many times at this point to remember what-compatible-where. Layers in einops==0.7.0 (and several prior versions) are compatible with TF 2.13 Layers in einops==0.8.0 were re-implemented acc...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/packing.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.031587
from collections.abc import Sequence from functools import lru_cache from typing import TypeAlias from einops import EinopsError from einops._backends import get_backend from einops.einops import Tensor from einops.parsing import ParsedExpression Shape: TypeAlias = Sequence[int] @lru_cache(maxsize=128) def analyze_...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/paddle.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.041491
from typing import cast import paddle from . import RearrangeMixin, ReduceMixin from ._einmix import _EinmixMixin __author__ = "PaddlePaddle" class Rearrange(RearrangeMixin, paddle.nn.Layer): def forward(self, input): return self._apply_recipe(input) class Reduce(ReduceMixin, paddle.nn.Layer): de...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/keras.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.054340
__author__ = "Alex Rogozhnikov" from einops.layers.tensorflow import EinMix, Rearrange, Reduce keras_custom_objects = { Rearrange.__name__: Rearrange, Reduce.__name__: Reduce, EinMix.__name__: EinMix, }
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/oneflow.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.058152
from typing import cast import oneflow as flow from . import RearrangeMixin, ReduceMixin from ._einmix import _EinmixMixin __author__ = "Tianhe Ren & Depeng Liang" class Rearrange(RearrangeMixin, flow.nn.Module): def forward(self, input): return self._apply_recipe(input) class Reduce(ReduceMixin, flo...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/layers/torch.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.059501
from typing import cast import torch from einops._torch_specific import apply_for_scriptable_torch from . import RearrangeMixin, ReduceMixin from ._einmix import _EinmixMixin __author__ = "Alex Rogozhnikov" class Rearrange(RearrangeMixin, torch.nn.Module): def forward(self, input): recipe = self._mult...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/parsing.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.083436
import keyword import warnings from einops import EinopsError _ellipsis: str = "…" # NB, this is a single unicode symbol. String is used as it is not a list, but can be iterated class AnonymousAxis: """Important thing: all instances of this class are not equal to each other""" def __init__(self, value: st...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.095997
""" Common utils for testing. These functions allow testing only some frameworks, not all. """ import logging import os import warnings from functools import lru_cache from einops import _backends __author__ = "Alex Rogozhnikov" # minimize noise in tests logging logging.getLogger("tensorflow").disabled = True logg...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/run_tests.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.117519
""" Runs tests that are appropriate for framework. """ import os import sys from pathlib import Path from subprocess import Popen __author__ = "Alex Rogozhnikov" def run(cmd, **env): # keeps printing output when testing cmd = cmd.split(" ") if isinstance(cmd, str) else cmd print("running:", cmd) p =...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_array_api.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.607390
import itertools import numpy as np import pytest from einops import rearrange, reduce, repeat from .test_ops import equivalent_rearrange_patterns, equivalent_reduction_patterns, identity_patterns, repeat_test_cases def test_rearrange_array_api(): import numpy as xp from einops import array_api as AA ...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_examples.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.642302
import numpy as np import pytest from einops import parse_shape, rearrange, reduce from einops.tests import is_backend_tested from einops.tests.test_ops import imp_op_backends def test_rearrange_examples(): def test1(x): # transpose y = rearrange(x, "b c h w -> b h w c") assert tuple(y.sh...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_layers.py
null
null
null
null
null
null
Python
2026-05-04T02:05:08.657365
import pickle from collections import namedtuple import numpy as np import pytest from einops import EinopsError, rearrange, reduce from einops.tests import FLOAT_REDUCTIONS as REDUCTIONS from einops.tests import collect_test_backends, is_backend_tested __author__ = "Alex Rogozhnikov" testcase = namedtuple("testcas...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
scripts/convert_readme.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.028110
""" Converts readme from github repo page to mkdocs-friendly """ from pathlib import Path original_text = Path(__file__).parent.parent.joinpath("README.md").read_text(encoding="utf-8") def replace_with_video_tag(line: str): if line.startswith("https://") and line.endswith(".mp4") and " " not in line: # ...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_einsum.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.029085
import string from collections.abc import Callable from typing import Any import numpy as np import pytest from einops.einops import EinopsError, _compactify_pattern_for_einsum, einsum from einops.tests import collect_test_backends class Arguments: def __init__(self, *args: Any, **kargs: Any): self.args...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_parsing.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.029823
import pytest from einops import EinopsError from einops.parsing import AnonymousAxis, ParsedExpression, _ellipsis __author__ = "Alex Rogozhnikov" class AnonymousAxisPlaceholder: def __init__(self, value: int): self.value = value assert isinstance(self.value, int) def __eq__(self, other): ...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
scripts/pytorch_examples_source/converter.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.030321
# type: ignore """ just run this script with python converter.py . It will convert pytorch.ipynb to html page docs/pytorch-examples.html """ from pathlib import Path import markdown import nbformat from pygments import highlight from pygments.formatters import HtmlFormatter from pygments.lexers import PythonLexer n...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_ops.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.030961
import itertools import numpy as np import pytest from einops import EinopsError from einops.einops import _enumerate_directions, rearrange, reduce, repeat from einops.tests import FLOAT_REDUCTIONS as REDUCTIONS from einops.tests import collect_test_backends, is_backend_tested imp_op_backends = collect_test_backends...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_other.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.031517
import subprocess import tempfile from doctest import testmod from pathlib import Path import numpy as np import pytest import einops import einops.layers from einops._backends import AbstractBackend from einops.einops import _optimize_transformation, parse_shape, rearrange from einops.tests import collect_test_backe...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
einops/tests/test_packing.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.172795
import dataclasses import numpy as np import pytest from einops import EinopsError, asnumpy, pack, unpack from einops.tests import collect_test_backends rng = np.random.default_rng() def pack_unpack(xs, pattern): x, ps = pack(xs, pattern) unpacked = unpack(xs, ps, pattern) assert len(unpacked) == len(x...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
scripts/test_notebooks.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.838054
""" Script assumes torch, tf and numpy are already installed. Also needs: "nbformat", "nbconvert", "jupyter", "pillow", """ from io import StringIO __author__ = "Alex Rogozhnikov" from pathlib import Path import nbformat from nbconvert.preprocessors import ExecutePreprocessor def render_notebook(filename...
arogozhnikov/einops
https://github.com/arogozhnikov/einops
null
null
null
null
9,476
null
null
mit
null
null
null
null
null
null
null
scripts/setup.py
null
null
null
null
null
null
Python
2026-05-04T02:05:09.867680
""" This is a fake script, it is not used. Github does not count dependent python projects unless you have a setup.py """ __author__ = "Alex Rogozhnikov" from pathlib import Path from setuptools import setup setup( name="einops", version="0.7.0", description="A new flavour of deep learning operations", ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/11_Dyna_Q/maze_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.379276
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the environment part of this example. The RL is in RL_brain.py. View more o...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/10_A3C/A3C_discrete_action.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.382847
""" Asynchronous Advantage Actor Critic (A3C) with discrete action space, Reinforcement Learning. The Cartpole example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.8.0 gym 0.10.5 """ import multiprocessing import threading import tensorflow as tf import numpy as np imp...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/12_Proximal_Policy_Optimization/simply_PPO.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.384838
""" A simple version of Proximal Policy Optimization (PPO) using single thread. Based on: 1. Emergence of Locomotion Behaviours in Rich Environments (Google Deepmind): [https://arxiv.org/abs/1707.02286] 2. Proximal Policy Optimization Algorithms (OpenAI): [https://arxiv.org/abs/1707.06347] View more on my tutorial we...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/12_Proximal_Policy_Optimization/discrete_DPPO.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.386013
""" A simple version of OpenAI's Proximal Policy Optimization (PPO). [https://arxiv.org/abs/1707.06347] Distributing workers in parallel to collect data, then stop worker's roll-out and train PPO on collected data. Restart workers once PPO is updated. The global PPO updating rule is adopted from DeepMind's paper (DPP...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/12_Proximal_Policy_Optimization/DPPO.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.391013
""" A simple version of OpenAI's Proximal Policy Optimization (PPO). [https://arxiv.org/abs/1707.06347] Distributing workers in parallel to collect data, then stop worker's roll-out and train PPO on collected data. Restart workers once PPO is updated. The global PPO updating rule is adopted from DeepMind's paper (DPP...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/10_A3C/A3C_distributed_tf.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.392569
""" Asynchronous Advantage Actor Critic (A3C) with discrete action space, Reinforcement Learning. The Cartpole example using distributed tensorflow + multiprocessing. View more on my tutorial page: https://morvanzhou.github.io/ """ import multiprocessing as mp import tensorflow as tf import numpy as np import gym, ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/11_Dyna_Q/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.394465
""" This part of code is the Dyna-Q learning brain, which is a brain of the agent. All decisions and learning processes are made in here. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ """ import numpy as np import pandas as pd class QLearningTable: def __init__(self, actions, learning_r...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/10_A3C/A3C_continuous_action.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.395754
""" Asynchronous Advantage Actor Critic (A3C) with continuous action space, Reinforcement Learning. The Pendulum example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.8.0 gym 0.10.5 """ import multiprocessing import threading import tensorflow as tf import numpy as np i...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/11_Dyna_Q/run_this.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.398558
""" Simplest model-based RL, Dyna-Q. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the main part which controls the update method of this example. The RL is in RL_...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/10_A3C/A3C_RNN.py
null
null
null
null
null
null
Python
2026-05-04T02:05:12.403549
""" Asynchronous Advantage Actor Critic (A3C) + RNN with continuous action space, Reinforcement Learning. The Pendulum example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.8.0 gym 0.10.5 """ import multiprocessing import threading import tensorflow as tf import numpy a...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/2_Q_Learning_maze/run_this.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.218338
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the main part which controls the update method of this example. The RL is in...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/4_Sarsa_lambda_maze/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.385270
""" This part of code is the Q learning brain, which is a brain of the agent. All decisions are made in here. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ """ import numpy as np import pandas as pd class RL(object): def __init__(self, action_space, learning_rate=0.01, reward_decay=0.9,...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/1_command_line_reinforcement_learning/treasure_on_right.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.388170
""" A simple example for Reinforcement Learning using table lookup Q-learning method. An agent "o" is on the left of a 1 dimensional world, the treasure is on the rightmost location. Run this program and to see how the agent will improve its strategy of finding the treasure. View more on my tutorial page: https://morv...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/4_Sarsa_lambda_maze/run_this.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.389862
""" Sarsa is a online updating method for Reinforcement learning. Unlike Q learning which is a offline updating method, Sarsa is updating while in the current trajectory. You will see the sarsa is more coward when punishment is close because it cares about all behaviours, while q learning is more brave because it onl...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/4_Sarsa_lambda_maze/maze_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.399443
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the environment part of this example. The RL is in RL_brain.py. View more o...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/3_Sarsa_maze/maze_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:13.402188
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the environment part of this example. The RL is in RL_brain.py. View more o...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/2_Q_Learning_maze/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.068583
""" This part of code is the Q learning brain, which is a brain of the agent. All decisions are made in here. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ """ import numpy as np import pandas as pd class QLearningTable: def __init__(self, actions, learning_rate=0.01, reward_decay=0.9, ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/2_Q_Learning_maze/maze_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.146520
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the environment part of this example. The RL is in RL_brain.py. View more o...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/3_Sarsa_maze/run_this.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.151140
""" Sarsa is a online updating method for Reinforcement learning. Unlike Q learning which is a offline updating method, Sarsa is updating while in the current trajectory. You will see the sarsa is more coward when punishment is close because it cares about all behaviours, while q learning is more brave because it onl...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.1_Double_DQN/run_Pendulum.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.657856
""" Double DQN & Natural DQN comparison, The Pendulum example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import DoubleDQN import numpy as np import matplotlib.pyplot as plt import tensorflow as tf env = gym.make('Pendulum-...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.3_Dueling_DQN/run_Pendulum.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.659728
""" Dueling DQN & Natural DQN comparison View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import DuelingDQN import numpy as np import matplotlib.pyplot as plt import tensorflow as tf env = gym.make('Pendulum-v0') env = env.unwrap...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.3_Dueling_DQN/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.661531
""" The Dueling DQN based on this paper: https://arxiv.org/abs/1511.06581 View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import numpy as np import tensorflow as tf np.random.seed(1) tf.set_random_seed(1) class DuelingDQN: def __init__( ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.2_Prioritized_Replay_DQN/run_MountainCar.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.662622
""" The DQN improvement: Prioritized Experience Replay (based on https://arxiv.org/abs/1511.05952) View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import DQNPrioritizedReplay import matplotlib.pyplot as plt import tensorflow as tf...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.2_Prioritized_Replay_DQN/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:14.664221
""" The DQN improvement: Prioritized Experience Replay (based on https://arxiv.org/abs/1511.05952) View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import numpy as np import tensorflow as tf np.random.seed(1) tf.set_random_seed(1) class SumTree(object): ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5.1_Double_DQN/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:15.487450
""" The double DQN based on this paper: https://arxiv.org/abs/1509.06461 View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import numpy as np import tensorflow as tf np.random.seed(1) tf.set_random_seed(1) class DoubleDQN: def __init__( se...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/3_Sarsa_maze/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:15.488553
""" This part of code is the Q learning brain, which is a brain of the agent. All decisions are made in here. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ """ import numpy as np import pandas as pd class RL(object): def __init__(self, action_space, learning_rate=0.01, reward_decay=0.9,...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5_Deep_Q_Network/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:15.489853
""" This part of code is the DQN brain, which is a brain of the agent. All decisions are made in here. Using Tensorflow to build the neural network. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.7.3 """ import numpy as np import pandas as pd import tensorflow as...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5_Deep_Q_Network/DQN_modified.py
null
null
null
null
null
null
Python
2026-05-04T02:05:15.795488
""" This part of code is the Deep Q Network (DQN) brain. view the tensorboard picture about this DQN structure on: https://morvanzhou.github.io/tutorials/machine-learning/reinforcement-learning/4-3-DQN3/#modification View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: r1.2 """ ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/7_Policy_gradient_softmax/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:15.827557
""" This part of code is the reinforcement learning brain, which is a brain of the agent. All decisions are made in here. Policy Gradient, Reinforcement Learning. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import numpy as np import tensorflow as tf ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/8_Actor_Critic_Advantage/AC_CartPole.py
null
null
null
null
null
null
Python
2026-05-04T02:05:16.697938
""" Actor-Critic using TD-error as the Advantage, Reinforcement Learning. The cart pole example. Policy is oscillated. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.0 gym 0.8.0 """ import numpy as np import tensorflow as tf import gym np.random.seed(2) tf.set_random_see...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/7_Policy_gradient_softmax/run_CartPole.py
null
null
null
null
null
null
Python
2026-05-04T02:05:16.698498
""" Policy Gradient, Reinforcement Learning. The cart pole example View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import PolicyGradient import matplotlib.pyplot as plt DISPLAY_REWARD_THRESHOLD = 400 # renders environment if tot...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/9_Deep_Deterministic_Policy_Gradient_DDPG/DDPG_update2.py
null
null
null
null
null
null
Python
2026-05-04T02:05:17.276234
""" Note: This is a updated version from my previous code, for the target network, I use moving average to soft replace target parameters instead using assign function. By doing this, it has 20% speed up on my machine (CPU). Deep Deterministic Policy Gradient (DDPG), Reinforcement Learning. DDPG is Actor Critic based ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/9_Deep_Deterministic_Policy_Gradient_DDPG/DDPG_update.py
null
null
null
null
null
null
Python
2026-05-04T02:05:17.277296
""" Deep Deterministic Policy Gradient (DDPG), Reinforcement Learning. DDPG is Actor Critic based algorithm. Pendulum example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.0 gym 0.8.0 """ import tensorflow as tf import numpy as np import gym import time ###############...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/7_Policy_gradient_softmax/run_MountainCar.py
null
null
null
null
null
null
Python
2026-05-04T02:05:17.506828
""" Policy Gradient, Reinforcement Learning. The cart pole example View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import PolicyGradient import matplotlib.pyplot as plt DISPLAY_REWARD_THRESHOLD = -2000 # renders environment if t...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/Curiosity_Model/Curiosity.py
null
null
null
null
null
null
Python
2026-05-04T02:05:17.857201
"""This is a simple implementation of [Large-Scale Study of Curiosity-Driven Learning](https://arxiv.org/abs/1808.04355)""" import numpy as np import tensorflow as tf import gym import matplotlib.pyplot as plt class CuriosityNet: def __init__( self, n_a, n_s, lr=0....
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/Curiosity_Model/Random_Network_Distillation.py
null
null
null
null
null
null
Python
2026-05-04T02:05:17.858381
"""This is a simple implementation of [Exploration by Random Network Distillation](https://arxiv.org/abs/1810.12894)""" import numpy as np import tensorflow as tf import gym import matplotlib.pyplot as plt class CuriosityNet: def __init__( self, n_a, n_s, lr=0.01, ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/2D_car/DDPG.py
null
null
null
null
null
null
Python
2026-05-04T02:05:18.147349
""" Environment is a 2D car. Car has 5 sensors to obtain distance information. Car collision => reward = -1, otherwise => reward = 0. You can train this RL by using LOAD = False, after training, this model will be store in the a local folder. Using LOAD = True to reload the trained model for playing. You can custom...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/2D_car/car_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:18.419924
""" Environment for 2D car driving. You can customize this script in a way you want. View more on [莫烦Python] : https://morvanzhou.github.io/tutorials/ Requirement: pyglet >= 1.2.4 numpy >= 1.12.1 """ import numpy as np import pyglet pyglet.clock.set_fps_limit(10000) class CarEnv(object): n_sensor = 5 act...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/2D_car/collision.py
null
null
null
null
null
null
Python
2026-05-04T02:05:18.438979
import numpy as np def intersection(): p = np.array([0, 0]) r = np.array([1, 1]) q = np.array([0.1, 0.1]) s = np.array([.1, .1]) if np.cross(r, s) == 0 and np.cross((q-p), r) == 0: # collinear # t0 = (q − p) · r / (r · r) # t1 = (q + s − p) · r / (r · r) = t0 + s · r / (r · r) ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/Robot_arm/A3C.py
null
null
null
null
null
null
Python
2026-05-04T02:05:18.736113
""" Environment is a Robot Arm. The arm tries to get to the blue point. The environment will return a geographic (distance) information for the arm to learn. The far away from blue point the less reward; touch blue r+=1; stop at blue for a while then get r=+10. You can train this RL by using LOAD = False, after trai...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/Robot_arm/DDPG.py
null
null
null
null
null
null
Python
2026-05-04T02:05:18.972194
""" Environment is a Robot Arm. The arm tries to get to the blue point. The environment will return a geographic (distance) information for the arm to learn. The far away from blue point the less reward; touch blue r+=1; stop at blue for a while then get r=+10. You can train this RL by using LOAD = False, after trai...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/Robot_arm/DPPO.py
null
null
null
null
null
null
Python
2026-05-04T02:05:19.008245
""" A simple version of OpenAI's Proximal Policy Optimization (PPO). [http://adsabs.harvard.edu/abs/2017arXiv170706347S] Distributing workers in parallel to collect data, then stop worker's roll-out and train PPO on collected data. Restart workers once PPO is updated. The global PPO updating rule is adopted from Deep...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
experiments/Robot_arm/arm_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:19.357499
""" Environment for Robot Arm. You can customize this script in a way you want. View more on [莫烦Python] : https://morvanzhou.github.io/tutorials/ Requirement: pyglet >= 1.2.4 numpy >= 1.12.1 """ import numpy as np import pyglet pyglet.clock.set_fps_limit(10000) class ArmEnv(object): action_bound = [-1, 1] ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5_Deep_Q_Network/maze_env.py
null
null
null
null
null
null
Python
2026-05-04T02:05:20.097647
""" Reinforcement learning maze example. Red rectangle: explorer. Black rectangles: hells [reward = -1]. Yellow bin circle: paradise [reward = +1]. All other states: ground [reward = 0]. This script is the environment part of this example. The RL is in RL_brain.py. View more o...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/9_Deep_Deterministic_Policy_Gradient_DDPG/DDPG.py
null
null
null
null
null
null
Python
2026-05-04T02:05:21.601477
""" Deep Deterministic Policy Gradient (DDPG), Reinforcement Learning. DDPG is Actor Critic based algorithm. Pendulum example. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: tensorflow 1.0 gym 0.8.0 """ import tensorflow as tf import numpy as np import gym import time np.random.seed(...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/8_Actor_Critic_Advantage/AC_continue_Pendulum.py
null
null
null
null
null
null
Python
2026-05-04T02:05:21.601947
""" Actor-Critic with continuous action using TD-error as the Advantage, Reinforcement Learning. The Pendulum example (based on https://github.com/dennybritz/reinforcement-learning/blob/master/PolicyGradient/Continuous%20MountainCar%20Actor%20Critic%20Solution.ipynb) Cannot converge!!! oscillate!!! View more on my t...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/5_Deep_Q_Network/run_this.py
null
null
null
null
null
null
Python
2026-05-04T02:05:25.389890
from maze_env import Maze from RL_brain import DeepQNetwork def run_maze(): step = 0 for episode in range(300): # initial observation observation = env.reset() while True: # fresh env env.render() # RL choose action based on observation ...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/6_OpenAI_gym/run_CartPole.py
null
null
null
null
null
null
Python
2026-05-04T02:05:25.391364
""" Deep Q network, Using: Tensorflow: 1.0 gym: 0.7.3 """ import gym from RL_brain import DeepQNetwork env = gym.make('CartPole-v0') env = env.unwrapped print(env.action_space) print(env.observation_space) print(env.observation_space.high) print(env.observation_space.low) RL = DeepQNetwork(n_actions=env.action_sp...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/6_OpenAI_gym/run_MountainCar.py
null
null
null
null
null
null
Python
2026-05-04T02:05:25.392136
""" Deep Q network, Using: Tensorflow: 1.0 gym: 0.8.0 """ import gym from RL_brain import DeepQNetwork env = gym.make('MountainCar-v0') env = env.unwrapped print(env.action_space) print(env.observation_space) print(env.observation_space.high) print(env.observation_space.low) RL = DeepQNetwork(n_actions=3, n_featu...
MorvanZhou/Reinforcement-learning-with-tensorflow
https://github.com/MorvanZhou/Reinforcement-learning-with-tensorflow
null
null
null
null
9,455
null
null
mit
null
null
null
null
null
null
null
contents/6_OpenAI_gym/RL_brain.py
null
null
null
null
null
null
Python
2026-05-04T02:05:25.392796
""" This part of code is the DQN brain, which is a brain of the agent. All decisions are made in here. Using Tensorflow to build the neural network. View more on my tutorial page: https://morvanzhou.github.io/tutorials/ Using: Tensorflow: 1.0 gym: 0.8.0 """ import numpy as np import pandas as pd import tensorflow as...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/config/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.043292
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .defaults import _C as cfg
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
demo/webcam.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.054201
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import argparse import cv2 from maskrcnn_benchmark.config import cfg from predictor import COCODemo import time def main(): parser = argparse.ArgumentParser(description="PyTorch Object Detection Webcam Demo") parser.add_argument( ...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
demo/predictor.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.054804
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import cv2 import torch from torchvision import transforms as T from torchvision.transforms import functional as F from maskrcnn_benchmark.modeling.detector import build_detection_model from maskrcnn_benchmark.utils.checkpoint import DetectronCheck...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/config/paths_catalog.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.057028
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. """Centralized catalog of paths.""" import os from copy import deepcopy class DatasetCatalog(object): DATA_DIR = "datasets" DATASETS = { "coco_2017_train": { "img_dir": "coco/train2017", "ann_file": "coco/a...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/build.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.059371
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import bisect import copy import logging import torch.utils.data from maskrcnn_benchmark.utils.comm import get_world_size from maskrcnn_benchmark.utils.imports import import_file from maskrcnn_benchmark.utils.miscellaneous import save_labels from...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/collate_batch.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.062374
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from maskrcnn_benchmark.structures.image_list import to_image_list class BatchCollator(object): """ From a list of samples from the dataset, returns the batched images and targets. This should be passed to the DataLoader """ ...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/config/defaults.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.063586
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import os from yacs.config import CfgNode as CN # ----------------------------------------------------------------------------- # Convention about Training / Test specific parameters # ------------------------------------------------------------...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
docker/docker-jupyter/jupyter_notebook_config.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.074891
import os from IPython.lib import passwd # c = c # pylint:disable=undefined-variable c = get_config() c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.port = int(os.getenv('PORT', 8888)) c.NotebookApp.open_browser = False # sets a password if PASSWORD is set in the environment if 'PASSWORD' in os.environ: password = o...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.077938
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .build import make_data_loader
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/datasets/__init__.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.622613
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. from .coco import COCODataset from .voc import PascalVOCDataset from .concat_dataset import ConcatDataset from .abstract import AbstractDataset from .cityscapes import CityScapesDataset __all__ = [ "COCODataset", "ConcatDataset", "Pas...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/datasets/evaluation/cityscapes/cityscapes_eval.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.694683
import logging import tempfile import os import torch from collections import OrderedDict from tqdm import tqdm from copy import deepcopy import torch import numpy as np from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker from maskrcnn_benchmark.structures.bounding_box import BoxList from mas...
facebookresearch/maskrcnn-benchmark
https://github.com/facebookresearch/maskrcnn-benchmark
null
null
null
null
9,378
null
null
mit
null
null
null
null
null
null
null
maskrcnn_benchmark/data/datasets/coco.py
null
null
null
null
null
null
Python
2026-05-04T02:05:28.705972
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. import torch import torchvision from maskrcnn_benchmark.structures.bounding_box import BoxList from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask from maskrcnn_benchmark.structures.keypoint import PersonKeypoints min_ke...