repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
rllab
rllab-master/rllab/envs/box2d/mountain_car_env.py
import numpy as np import pygame from rllab.envs.box2d.parser import find_body from rllab.core.serializable import Serializable from rllab.envs.box2d.box2d_env import Box2DEnv from rllab.misc import autoargs from rllab.misc.overrides import overrides class MountainCarEnv(Box2DEnv, Serializable): @autoargs.inher...
1,964
29.703125
77
py
rllab
rllab-master/rllab/envs/box2d/box2d_env.py
import os.path as osp import mako.lookup import mako.template import numpy as np from rllab import spaces from rllab.envs.base import Env, Step from rllab.envs.box2d.box2d_viewer import Box2DViewer from rllab.envs.box2d.parser.xml_box2d import world_from_xml, find_body, \ find_joint from rllab.misc import autoar...
13,078
35.229917
85
py
rllab
rllab-master/rllab/envs/box2d/double_pendulum_env.py
import numpy as np from rllab.envs.box2d.parser import find_body from rllab.core.serializable import Serializable from rllab.envs.box2d.box2d_env import Box2DEnv from rllab.misc import autoargs from rllab.misc.overrides import overrides # http://mlg.eng.cam.ac.uk/pilco/ class DoublePendulumEnv(Box2DEnv, Serializable...
2,093
32.238095
65
py
rllab
rllab-master/rllab/envs/box2d/cartpole_env.py
import numpy as np from rllab.envs.box2d.parser import find_body from rllab.core.serializable import Serializable from rllab.envs.box2d.box2d_env import Box2DEnv from rllab.misc import autoargs from rllab.misc.overrides import overrides class CartpoleEnv(Box2DEnv, Serializable): @autoargs.inherit(Box2DEnv.__ini...
1,908
31.913793
70
py
rllab
rllab-master/rllab/envs/box2d/box2d_viewer.py
from Box2D import b2ContactListener, b2Vec2, b2DrawExtended import pygame from pygame import (QUIT, KEYDOWN, KEYUP, MOUSEBUTTONDOWN, MOUSEMOTION) class PygameDraw(b2DrawExtended): """ This debug draw class accepts callbacks from Box2D (which specifies what to draw) and handles all of the rendering. I...
9,331
31.975265
79
py
rllab
rllab-master/rllab/envs/box2d/cartpole_swingup_env.py
import numpy as np import pygame from rllab.envs.box2d.parser import find_body from rllab.core.serializable import Serializable from rllab.envs.box2d.box2d_env import Box2DEnv from rllab.misc import autoargs from rllab.misc.overrides import overrides # Tornio, Matti, and Tapani Raiko. "Variational Bayesian approach ...
2,167
30.882353
71
py
rllab
rllab-master/rllab/envs/box2d/car_parking_env.py
import numpy as np import pygame from rllab.envs.box2d.box2d_env import Box2DEnv from rllab.envs.box2d.parser import find_body from rllab.core.serializable import Serializable from rllab.envs.box2d.parser.xml_box2d import _get_name from rllab.misc import autoargs from rllab.misc.overrides import overrides class CarP...
4,347
36.162393
97
py
rllab
rllab-master/rllab/envs/box2d/__init__.py
0
0
0
py
rllab
rllab-master/rllab/envs/box2d/parser/xml_box2d.py
# pylint: disable=no-init, too-few-public-methods, old-style-class import xml.etree.ElementTree as ET import Box2D import numpy as np from rllab.envs.box2d.parser.xml_types import XmlElem, XmlChild, XmlAttr, \ XmlChildren from rllab.envs.box2d.parser.xml_attr_types import Tuple, Float, Choice, \ String, List...
11,482
30.546703
89
py
rllab
rllab-master/rllab/envs/box2d/parser/xml_attr_types.py
# pylint: disable=no-init, too-few-public-methods, old-style-class import numpy as np class Type(object): def __eq__(self, other): return self.__class__ == other.__class__ def from_str(self, s): raise NotImplementedError class Float(Type): def from_str(self, s): return float(...
2,807
21.285714
82
py
rllab
rllab-master/rllab/envs/box2d/parser/xml_types.py
# pylint: disable=no-init, too-few-public-methods, old-style-class from types import LambdaType def _extract_type(typ): if isinstance(typ, LambdaType): return typ() else: return typ class AttrDecl(object): pass class XmlChildren(AttrDecl): def __init__(self, tag, typ): se...
3,055
26.781818
79
py
rllab
rllab-master/rllab/envs/box2d/parser/__init__.py
from .xml_box2d import world_from_xml, find_body, find_joint
61
30
60
py
rllab
rllab-master/rllab/distributions/recurrent_diagonal_gaussian.py
import theano.tensor as TT import numpy as np from rllab.distributions.base import Distribution from rllab.distributions.diagonal_gaussian import DiagonalGaussian RecurrentDiagonalGaussian = DiagonalGaussian
209
29
66
py
rllab
rllab-master/rllab/distributions/base.py
import theano.tensor as TT class Distribution(object): @property def dim(self): raise NotImplementedError def kl_sym(self, old_dist_info_vars, new_dist_info_vars): """ Compute the symbolic KL divergence of two distributions """ raise NotImplementedError def kl...
1,033
25.512821
82
py
rllab
rllab-master/rllab/distributions/categorical.py
import theano.tensor as TT import numpy as np from .base import Distribution from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams TINY = 1e-8 # def from_onehot_sym(x_var): # ret = TT.zeros((x_var.shape[0],), x_var.dtype) # nonzero_n, nonzero_a = TT.nonzero(x_var)[:2] # ret = TT.set_subte...
2,797
30.795455
110
py
rllab
rllab-master/rllab/distributions/recurrent_categorical.py
import theano.tensor as TT import numpy as np import theano from rllab.distributions.categorical import Categorical from rllab.distributions.base import Distribution TINY = 1e-8 class RecurrentCategorical(Distribution): def __init__(self, dim): self._cat = Categorical(dim) self._dim = dim @p...
2,585
33.026316
113
py
rllab
rllab-master/rllab/distributions/__init__.py
0
0
0
py
rllab
rllab-master/rllab/distributions/delta.py
from rllab.distributions.base import Distribution class Delta(Distribution): @property def dim(self): return 0 def kl_sym(self, old_dist_info_vars, new_dist_info_vars): return None def kl(self, old_dist_info, new_dist_info): return None def likelihood_ratio_sym(self, x_va...
865
23.742857
82
py
rllab
rllab-master/rllab/distributions/diagonal_gaussian.py
import theano.tensor as TT import numpy as np from rllab.distributions.base import Distribution class DiagonalGaussian(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): o...
3,610
36.226804
82
py
rllab
rllab-master/rllab/distributions/bernoulli.py
from .base import Distribution import theano.tensor as TT import numpy as np TINY = 1e-8 class Bernoulli(Distribution): def __init__(self, dim): self._dim = dim @property def dim(self): return self._dim def kl_sym(self, old_dist_info_vars, new_dist_info_vars): old_p = old_...
1,891
32.192982
103
py
rllab
rllab-master/rllab/policies/base.py
from rllab.core.parameterized import Parameterized class Policy(Parameterized): def __init__(self, env_spec): Parameterized.__init__(self) self._env_spec = env_spec # Should be implemented by all policies def get_action(self, observation): raise NotImplementedError def reset...
2,093
24.536585
117
py
rllab
rllab-master/rllab/policies/uniform_control_policy.py
from rllab.core.parameterized import Parameterized from rllab.core.serializable import Serializable from rllab.distributions.delta import Delta from rllab.policies.base import Policy from rllab.misc.overrides import overrides class UniformControlPolicy(Policy): def __init__( self, env_spec...
928
24.108108
69
py
rllab
rllab-master/rllab/policies/categorical_gru_policy.py
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano.tensor as TT from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import GRUNetwork from rllab.core.lasagne_layers import OpLayer from rllab.core.serializable import Serializable from rllab.distribu...
6,528
33.544974
101
py
rllab
rllab-master/rllab/policies/categorical_mlp_policy.py
import lasagne.layers as L import lasagne.nonlinearities as NL from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import MLP from rllab.core.serializable import Serializable from rllab.distributions.categorical import Categorical from rllab.misc import ext from rllab.misc.overrides import ov...
3,158
35.732558
95
py
rllab
rllab-master/rllab/policies/gaussian_mlp_policy.py
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np from rllab.core.lasagne_layers import ParamLayer from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import MLP from rllab.spaces import Box from rllab.core.serializable import Serializable from ...
6,192
37.228395
117
py
rllab
rllab-master/rllab/policies/gaussian_gru_policy.py
import lasagne.layers as L import lasagne.nonlinearities as NL import lasagne.init import numpy as np import theano.tensor as TT from rllab.core.lasagne_layers import ParamLayer from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import GRUNetwork from rllab.core.serializable import Serializa...
5,456
33.10625
107
py
rllab
rllab-master/rllab/policies/__init__.py
0
0
0
py
rllab
rllab-master/rllab/policies/categorical_conv_policy.py
from rllab.core.lasagne_powered import LasagnePowered import lasagne.layers as L from rllab.core.network import ConvNetwork from rllab.distributions.categorical import Categorical from rllab.policies.base import StochasticPolicy from rllab.misc import tensor_utils from rllab.spaces.discrete import Discrete from rllab....
3,623
33.514286
93
py
rllab
rllab-master/rllab/policies/deterministic_mlp_policy.py
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import lasagne.init as LI from rllab.core.lasagne_powered import LasagnePowered from rllab.core.lasagne_layers import batch_norm from rllab.core.serializable import Serializable from rllab.misc import ext from rllab.policies.base import Polic...
2,408
31.554054
79
py
rllab
rllab-master/rllab/baselines/gaussian_conv_baseline.py
import numpy as np from rllab.core.serializable import Serializable from rllab.misc.overrides import overrides from rllab.core.parameterized import Parameterized from rllab.baselines.base import Baseline from rllab.regressors.gaussian_conv_regressor import GaussianConvRegressor class GaussianConvBaseline(Baseline, P...
1,460
30.085106
74
py
rllab
rllab-master/rllab/baselines/zero_baseline.py
import numpy as np from rllab.baselines.base import Baseline from rllab.misc.overrides import overrides class ZeroBaseline(Baseline): def __init__(self, env_spec): pass @overrides def get_param_values(self, **kwargs): return None @overrides def set_param_values(self, val, **kwar...
484
17.653846
46
py
rllab
rllab-master/rllab/baselines/base.py
from rllab.misc import autoargs class Baseline(object): def __init__(self, env_spec): self._mdp_spec = env_spec @property def algorithm_parallelized(self): return False def get_param_values(self): raise NotImplementedError def set_param_values(self, val): raise ...
797
18.95
72
py
rllab
rllab-master/rllab/baselines/gaussian_mlp_baseline.py
import numpy as np from rllab.core.serializable import Serializable from rllab.core.parameterized import Parameterized from rllab.baselines.base import Baseline from rllab.misc.overrides import overrides from rllab.regressors.gaussian_mlp_regressor import GaussianMLPRegressor class GaussianMLPBaseline(Baseline, Para...
1,508
30.4375
80
py
rllab
rllab-master/rllab/baselines/linear_feature_baseline.py
from rllab.baselines.base import Baseline from rllab.misc.overrides import overrides import numpy as np class LinearFeatureBaseline(Baseline): def __init__(self, env_spec, reg_coeff=1e-5): self._coeffs = None self._reg_coeff = reg_coeff @overrides def get_param_values(self, **tags): ...
1,403
30.909091
89
py
rllab
rllab-master/rllab/baselines/__init__.py
0
0
0
py
rllab
rllab-master/rllab/algos/base.py
class Algorithm(object): pass class RLAlgorithm(Algorithm): def train(self): raise NotImplementedError
122
12.666667
33
py
rllab
rllab-master/rllab/algos/npo.py
from rllab.misc import ext from rllab.misc.overrides import overrides from rllab.algos.batch_polopt import BatchPolopt import rllab.misc.logger as logger import theano import theano.tensor as TT from rllab.optimizers.penalty_lbfgs_optimizer import PenaltyLbfgsOptimizer class NPO(BatchPolopt): """ Natural Poli...
4,746
34.691729
90
py
rllab
rllab-master/rllab/algos/vpg.py
import theano.tensor as TT import theano from rllab.misc import logger from rllab.misc.overrides import overrides from rllab.misc import ext from rllab.algos.batch_polopt import BatchPolopt from rllab.optimizers.first_order_optimizer import FirstOrderOptimizer from rllab.core.serializable import Serializable class VP...
4,777
33.128571
90
py
rllab
rllab-master/rllab/algos/ddpg.py
from rllab.algos.base import RLAlgorithm from rllab.misc.overrides import overrides from rllab.misc import special from rllab.misc import ext from rllab.sampler import parallel_sampler from rllab.plotter import plotter from functools import partial import rllab.misc.logger as logger import theano.tensor as TT import pi...
17,620
37.642544
114
py
rllab
rllab-master/rllab/algos/erwr.py
from rllab.algos.vpg import VPG from rllab.optimizers.lbfgs_optimizer import LbfgsOptimizer from rllab.core.serializable import Serializable class ERWR(VPG, Serializable): """ Episodic Reward Weighted Regression [1]_ Notes ----- This does not implement the original RwR [2]_ that deals with "immed...
1,374
37.194444
250
py
rllab
rllab-master/rllab/algos/cma_es.py
from rllab.algos.base import RLAlgorithm import theano.tensor as TT import numpy as np from rllab.misc import ext from rllab.misc.special import discount_cumsum from rllab.sampler import parallel_sampler, stateful_pool from rllab.sampler.utils import rollout from rllab.core.serializable import Serializable import rll...
5,759
35.923077
103
py
rllab
rllab-master/rllab/algos/ppo.py
from rllab.optimizers.penalty_lbfgs_optimizer import PenaltyLbfgsOptimizer from rllab.algos.npo import NPO from rllab.core.serializable import Serializable class PPO(NPO, Serializable): """ Penalized Policy Optimization. """ def __init__( self, optimizer=None, opti...
646
28.409091
74
py
rllab
rllab-master/rllab/algos/nop.py
from rllab.algos.batch_polopt import BatchPolopt from rllab.misc.overrides import overrides class NOP(BatchPolopt): """ NOP (no optimization performed) policy search algorithm """ def __init__( self, **kwargs): super(NOP, self).__init__(**kwargs) @overrides de...
519
19
59
py
rllab
rllab-master/rllab/algos/tnpg.py
from rllab.algos.npo import NPO from rllab.optimizers.conjugate_gradient_optimizer import ConjugateGradientOptimizer from rllab.misc import ext class TNPG(NPO): """ Truncated Natural Policy Gradient. """ def __init__( self, optimizer=None, optimizer_args=None, ...
727
29.333333
84
py
rllab
rllab-master/rllab/algos/trpo.py
from rllab.algos.npo import NPO from rllab.optimizers.conjugate_gradient_optimizer import ConjugateGradientOptimizer from rllab.core.serializable import Serializable class TRPO(NPO): """ Trust Region Policy Optimization """ def __init__( self, optimizer=None, optim...
603
27.761905
84
py
rllab
rllab-master/rllab/algos/util.py
import numpy as np import time from rllab.core.serializable import Serializable from rllab.misc.ext import extract def center_advantages(advantages): return (advantages - np.mean(advantages)) / (advantages.std() + 1e-8) def shift_advantages_to_positive(advantages): return (advantages - np.min(advantages)) +...
13,903
32.829684
79
py
rllab
rllab-master/rllab/algos/cma_es_lib.py
"""Module cma implements the CMA-ES (Covariance Matrix Adaptation Evolution Strategy). CMA-ES is a stochastic optimizer for robust non-linear non-convex derivative- and function-value-free numerical optimization. This implementation can be used with Python versions >= 2.6, namely 2.6, 2.7, 3.3, 3.4. CMA-ES searches ...
377,327
41.878182
276
py
rllab
rllab-master/rllab/algos/__init__.py
0
0
0
py
rllab
rllab-master/rllab/algos/cem.py
from itertools import chain, zip_longest from rllab.algos.base import RLAlgorithm import numpy as np from rllab.misc.special import discount_cumsum from rllab.sampler import parallel_sampler, stateful_pool from rllab.sampler.utils import rollout from rllab.core.serializable import Serializable import rllab.misc.logg...
7,274
39.19337
108
py
rllab
rllab-master/rllab/algos/reps.py
import theano.tensor as TT import theano import scipy.optimize from rllab.misc import logger from rllab.misc.overrides import overrides from rllab.misc import ext from rllab.algos.batch_polopt import BatchPolopt from rllab.core.serializable import Serializable import numpy as np from rllab.misc import tensor_utils cl...
12,115
34.323615
115
py
rllab
rllab-master/rllab/algos/batch_polopt.py
from rllab.algos.base import RLAlgorithm from rllab.sampler import parallel_sampler from rllab.sampler.base import BaseSampler import rllab.misc.logger as logger import rllab.plotter as plotter from rllab.policies.base import Policy class BatchSampler(BaseSampler): def __init__(self, algo): """ :t...
5,938
34.777108
111
py
rllab
rllab-master/rllab/spaces/box.py
from rllab.core.serializable import Serializable from .base import Space import numpy as np from rllab.misc import ext import theano class Box(Space): """ A box in R^n. I.e., each coordinate is bounded. """ def __init__(self, low, high, shape=None): """ Two kinds of valid input: ...
2,093
25.846154
103
py
rllab
rllab-master/rllab/spaces/base.py
import numpy as np class Space(object): """ Provides a classification state spaces and action spaces, so you can write generic code that applies to any Environment. E.g. to choose a random action. """ def sample(self, seed=0): """ Uniformly randomly sample a random elemnt of t...
1,309
24.686275
85
py
rllab
rllab-master/rllab/spaces/discrete.py
from .base import Space import numpy as np from rllab.misc import special from rllab.misc import ext class Discrete(Space): """ {0,1,...,n-1} """ def __init__(self, n): self._n = n @property def n(self): return self._n def sample(self): return np.random.randint(s...
1,835
21.666667
78
py
rllab
rllab-master/rllab/spaces/__init__.py
from .product import Product from .discrete import Discrete from .box import Box __all__ = ["Product", "Discrete", "Box"]
122
23.6
40
py
rllab
rllab-master/rllab/spaces/product.py
from rllab.spaces.base import Space import numpy as np from rllab.misc import ext class Product(Space): def __init__(self, *components): if isinstance(components[0], (list, tuple)): assert len(components) == 1 components = components[0] self._components = tuple(components)...
2,304
33.924242
97
py
rllab
rllab-master/rllab/mujoco_py/glfw.py
''' Python bindings for GLFW. ''' __author__ = 'Florian Rhiem (florian.rhiem@gmail.com)' __copyright__ = 'Copyright (c) 2013 Florian Rhiem' __license__ = 'MIT' __version__ = '1.0.1' import ctypes import os import glob import sys import subprocess import textwrap # Python 3 compatibility: try: _getcwd = os.ge...
54,410
32.217949
120
py
rllab
rllab-master/rllab/mujoco_py/mjviewer.py
import ctypes from ctypes import pointer, byref import logging from threading import Lock import os from . import mjcore, mjconstants, glfw from .mjlib import mjlib import numpy as np import OpenGL.GL as gl logger = logging.getLogger(__name__) mjCAT_ALL = 7 def _glfw_error_callback(e, d): logger.error('GLFW er...
10,788
31.893293
174
py
rllab
rllab-master/rllab/mujoco_py/mjextra.py
def append_objects(cur, extra): for i in range(cur.ngeom, cur.ngeom + extra.ngeom): cur.geoms[i] = extra.geoms[i - cur.ngeom] cur.ngeom = cur.ngeom + extra.ngeom if cur.ngeom > cur.maxgeom: raise ValueError("buffer limit exceeded!")
262
36.571429
55
py
rllab
rllab-master/rllab/mujoco_py/mjcore.py
from ctypes import create_string_buffer import ctypes from . import mjconstants as C from .mjtypes import * # import all for backwards compatibility from .mjlib import mjlib class MjError(Exception): pass def register_license(file_path): """ activates mujoco with license at `file_path` this does n...
5,531
33.575
159
py
rllab
rllab-master/rllab/mujoco_py/mjlib.py
from ctypes import * import os from .util import * from .mjtypes import * osp = os.path if sys.platform.startswith("darwin"): libfile = osp.abspath(osp.join(osp.dirname(__file__),"../../vendor/mujoco/libmujoco131.dylib")) elif sys.platform.startswith("linux"): libfile = osp.abspath(osp.join(osp.dirname(__file_...
22,701
54.101942
178
py
rllab
rllab-master/rllab/mujoco_py/mjtypes.py
# AUTO GENERATED. DO NOT CHANGE! from ctypes import * import numpy as np class MJCONTACT(Structure): _fields_ = [ ("dist", c_double), ("pos", c_double * 3), ("frame", c_double * 9), ("includemargin", c_double), ("friction", c_double * 5), ("solref", c_double * ...
224,081
35.849531
187
py
rllab
rllab-master/rllab/mujoco_py/util.py
import ctypes, os, sys from ctypes import * import six # MAXINT on Python 2, undefined on Python 3 MAXINT = 9223372036854775807 class UserString: def __init__(self, seq): if isinstance(seq, basestring): self.data = seq elif isinstance(seq, UserString): self.data = seq.data[...
9,058
38.047414
80
py
rllab
rllab-master/rllab/mujoco_py/__init__.py
from .mjviewer import MjViewer from .mjcore import MjModel from .mjcore import register_license import os from .mjconstants import * register_license(os.path.join(os.path.dirname(__file__), '../../vendor/mujoco/mjkey.txt'))
255
27.444444
63
py
rllab
rllab-master/rllab/mujoco_py/mjconstants.py
MOUSE_ROTATE_V = 1 MOUSE_ROTATE_H = 2 MOUSE_MOVE_V = 3 MOUSE_MOVE_H = 4 MOUSE_ZOOM = 5 mjOBJ_BODY = 1
103
12
18
py
rllab
rllab-master/rllab/misc/autoargs.py
from rllab.misc.console import colorize import inspect # pylint: disable=redefined-builtin # pylint: disable=protected-access def arg(name, type=None, help=None, nargs=None, mapper=None, choices=None, prefix=True): def wrap(fn): assert fn.__name__ == '__init__' if not hasattr(fn, '_autoarg...
4,540
29.072848
80
py
rllab
rllab-master/rllab/misc/resolve.py
from pydoc import locate import types from rllab.misc.ext import iscanr def classesinmodule(module): md = module.__dict__ return [ md[c] for c in md if ( isinstance(md[c], type) and md[c].__module__ == module.__name__ ) ] def locate_with_hint(class_path, prefix_hints=[]): ...
2,123
39.075472
124
py
rllab
rllab-master/rllab/misc/nb_utils.py
import os.path as osp import numpy as np import csv import matplotlib.pyplot as plt import json import joblib from glob import glob import os def plot_experiments(name_or_patterns, legend=False, post_processing=None, key='AverageReturn'): if not isinstance(name_or_patterns, (list, tuple)): name_or_pattern...
6,975
37.32967
110
py
rllab
rllab-master/rllab/misc/special.py
import numpy as np import scipy import scipy.signal import theano.tensor.nnet import theano.tensor as TT import theano.tensor.extra_ops from collections import OrderedDict def weighted_sample(weights, objects): """ Return a random item from objects, with the weighting defined by weights (which must sum to...
4,895
24.633508
103
py
rllab
rllab-master/rllab/misc/ext.py
from path import Path import sys import pickle as pickle import random from rllab.misc.console import colorize, Message from collections import OrderedDict import numpy as np import operator from functools import reduce sys.setrecursionlimit(50000) def extract(x, *keys): if isinstance(x, (dict, lazydict)): ...
12,215
30.163265
172
py
rllab
rllab-master/rllab/misc/instrument.py
import os import re import subprocess import base64 import os.path as osp import pickle as pickle import inspect import hashlib import sys from contextlib import contextmanager import errno from rllab.core.serializable import Serializable from rllab import config from rllab.misc.console import mkdir_p from rllab.misc...
54,609
38.658678
174
py
rllab
rllab-master/rllab/misc/tensor_utils.py
import operator import numpy as np def flatten_tensors(tensors): if len(tensors) > 0: return np.concatenate([np.reshape(x, [-1]) for x in tensors]) else: return np.asarray([]) def unflatten_tensors(flattened, tensor_shapes): tensor_sizes = list(map(np.prod, tensor_shapes)) indices =...
4,490
28.741722
108
py
rllab
rllab-master/rllab/misc/tabulate.py
# -*- coding: utf-8 -*- # Taken from John's code """Pretty-print tabular data.""" from collections import namedtuple from platform import python_version_tuple import re if python_version_tuple()[0] < "3": from itertools import izip_longest from functools import partial _none_type = type(None) _int...
28,995
33.072855
197
py
rllab
rllab-master/rllab/misc/logger.py
from enum import Enum from rllab.misc.tabulate import tabulate from rllab.misc.console import mkdir_p, colorize from rllab.misc.autoargs import get_all_parameters from contextlib import contextmanager import numpy as np import os import os.path as osp import sys import datetime import dateutil.tz import csv import job...
10,538
29.197708
93
py
rllab
rllab-master/rllab/misc/mako_utils.py
def compute_rect_vertices(fromp, to, radius): x1, y1 = fromp x2, y2 = to if abs(y1 - y2) < 1e-6: dx = 0 dy = radius else: dx = radius * 1.0 / (((x1 - x2) / (y1 - y2)) ** 2 + 1) ** 0.5 # equivalently dx = radius * (y2-y1).to_f / ((x2-x1)**2 + (y2-y1)**2)**0.5 dy =...
569
26.142857
82
py
rllab
rllab-master/rllab/misc/viewer2d.py
import pygame import pygame.gfxdraw import numpy as np class Colors(object): black = (0, 0, 0) white = (255, 255, 255) blue = (0, 0, 255) red = (255, 0, 0) green = (0, 255, 0) class Viewer2D(object): def __init__(self, size=(640, 480), xlim=None, ylim=None): pygame.init() scre...
4,668
33.330882
111
py
rllab
rllab-master/rllab/misc/__init__.py
0
0
0
py
rllab
rllab-master/rllab/misc/console.py
import sys import time import os import errno import shlex import pydoc import inspect import collections color2num = dict( gray=30, red=31, green=32, yellow=33, blue=34, magenta=35, cyan=36, white=37, crimson=38 ) def colorize(string, color, bold=False, highlight=False): attr...
6,692
28.615044
124
py
rllab
rllab-master/rllab/misc/overrides.py
# # Copyright 2015 Mikko Korpela # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in...
3,547
32.471698
120
py
rllab
rllab-master/rllab/misc/meta.py
0
0
0
py
rllab
rllab-master/rllab/misc/krylov.py
import numpy as np from rllab.misc.ext import sliced_fun EPS = np.finfo('float64').tiny def cg(f_Ax, b, cg_iters=10, callback=None, verbose=False, residual_tol=1e-10): """ Demmel p 312 """ p = b.copy() r = b.copy() x = np.zeros_like(b) rdotr = r.dot(r) fmtstr = "%10i %10.3g %10.3g" ...
5,760
24.604444
121
py
rllab
rllab-master/rllab/regressors/gaussian_mlp_regressor.py
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano import theano.tensor as TT from rllab.core.lasagne_layers import ParamLayer from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import MLP from rllab.core.serializable import Seriali...
10,913
38.258993
119
py
rllab
rllab-master/rllab/regressors/categorical_mlp_regressor.py
import lasagne.layers as L import lasagne.nonlinearities as NL import numpy as np import theano import theano.tensor as TT from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import MLP from rllab.core.serializable import Serializable from rllab.distributions.categorical import Categorical fr...
5,876
34.403614
119
py
rllab
rllab-master/rllab/regressors/gaussian_conv_regressor.py
import numpy as np import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import theano import theano.tensor as TT from rllab.misc.ext import compile_function from rllab.core.lasagne_layers import ParamLayer from rllab.core.lasagne_powered import LasagnePowered from rllab.core.network import Conv...
11,624
38.675768
119
py
rllab
rllab-master/rllab/regressors/product_regressor.py
import numpy as np from rllab.core.serializable import Serializable class ProductRegressor(Serializable): """ A class for performing MLE regression by fitting a product distribution to the outputs. A separate regressor will be trained for each individual input distribution. """ def __init__(se...
2,022
32.716667
117
py
rllab
rllab-master/rllab/regressors/__init__.py
__author__ = 'dementrock'
26
12.5
25
py
rllab
rllab-master/rllab/q_functions/base.py
from rllab.core.parameterized import Parameterized class QFunction(Parameterized): pass
94
14.833333
50
py
rllab
rllab-master/rllab/q_functions/continuous_mlp_q_function.py
import lasagne import lasagne.layers as L import lasagne.nonlinearities as NL import lasagne.init import theano.tensor as TT from rllab.q_functions.base import QFunction from rllab.core.lasagne_powered import LasagnePowered from rllab.core.lasagne_layers import batch_norm from rllab.core.serializable import Serializabl...
2,914
31.752809
94
py
rllab
rllab-master/rllab/q_functions/__init__.py
0
0
0
py
rllab
rllab-master/rllab/exploration_strategies/base.py
class ExplorationStrategy(object): def get_action(self, t, observation, policy, **kwargs): raise NotImplementedError def reset(self): pass
164
22.571429
59
py
rllab
rllab-master/rllab/exploration_strategies/__init__.py
0
0
0
py
rllab
rllab-master/rllab/exploration_strategies/ou_strategy.py
from rllab.misc.overrides import overrides from rllab.misc.ext import AttrDict from rllab.core.serializable import Serializable from rllab.spaces.box import Box from rllab.exploration_strategies.base import ExplorationStrategy import numpy as np import numpy.random as nr class OUStrategy(ExplorationStrategy, Serializ...
2,159
32.230769
113
py
rllab
rllab-master/rllab/exploration_strategies/gaussian_strategy.py
from rllab.core.serializable import Serializable from rllab.spaces.box import Box from rllab.exploration_strategies.base import ExplorationStrategy import numpy as np class GaussianStrategy(ExplorationStrategy, Serializable): """ This strategy adds Gaussian noise to the action taken by the deterministic polic...
1,118
42.038462
110
py
rllab
rllab-master/rllab/optimizers/first_order_optimizer.py
from rllab.misc import ext from rllab.misc import logger from rllab.core.serializable import Serializable # from rllab.algo.first_order_method import parse_update_method from rllab.optimizers.minibatch_dataset import BatchDataset from collections import OrderedDict import time import lasagne.updates import theano impor...
4,720
33.210145
112
py
rllab
rllab-master/rllab/optimizers/penalty_lbfgs_optimizer.py
from rllab.misc.ext import compile_function, lazydict, flatten_tensor_variables from rllab.misc import logger from rllab.core.serializable import Serializable import theano.tensor as TT import theano import numpy as np import scipy.optimize class PenaltyLbfgsOptimizer(Serializable): """ Performs constrained o...
6,910
41.925466
120
py
rllab
rllab-master/rllab/optimizers/hessian_free_optimizer.py
from rllab.misc.ext import compile_function, lazydict from rllab.core.serializable import Serializable from rllab.optimizers.hf import hf_optimizer import time from rllab.optimizers.minibatch_dataset import BatchDataset class HessianFreeOptimizer(Serializable): """ Performs unconstrained optimization via Hess...
2,936
32.758621
107
py
rllab
rllab-master/rllab/optimizers/hf.py
# Author: Nicolas Boulanger-Lewandowski # University of Montreal, 2012-2013 import numpy, sys import theano import theano.tensor as T import pickle import os from rllab.misc.ext import compile_function import collections def gauss_newton_product(cost, p, v, s): # this computes the product Gv = J'HJv (G is the Gaus...
15,714
42.896648
138
py
rllab
rllab-master/rllab/optimizers/conjugate_gradient_optimizer.py
from rllab.misc import ext from rllab.misc import krylov from rllab.misc import logger from rllab.core.serializable import Serializable import theano.tensor as TT import theano import itertools import numpy as np from rllab.misc.ext import sliced_fun from _ast import Num class PerlmutterHvp(Serializable): def __...
11,870
38.969697
119
py
rllab
rllab-master/rllab/optimizers/__init__.py
0
0
0
py
rllab
rllab-master/rllab/optimizers/minibatch_dataset.py
import numpy as np class BatchDataset(object): def __init__(self, inputs, batch_size, extra_inputs=None): self._inputs = [ i for i in inputs ] if extra_inputs is None: extra_inputs = [] self._extra_inputs = extra_inputs self._batch_size = batch_size...
1,233
30.641026
78
py