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 |
|---|---|---|---|---|---|---|
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/reacher2d.py | import numpy as np
import os
import os.path as osp
import signal
from gym import utils
from gym import spaces
from gym.envs.robotics.utils import mocap_set_action
from HER.envs import mujoco_env
class BaxterEnv(mujoco_env.MujocoEnv, utils.EzPickle):
"""cts env, 4dim
state space: absolute state space positi... | 5,639 | 32.571429 | 102 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/pusher.py | from HER.envs import reacher2d
import numpy as np
from HER.rcnn import renderer
from gym import spaces
import random
# we need the ability to tack on additional info onto our states, which are only
# partial observations of the environment. this is necessary because we need to
# be able to compute the reward based o... | 9,200 | 34.801556 | 106 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/active_pusher.py | from HER.envs import fakercnn_pusher
import numpy as np
import quaternion
from HER.envs.pusher import _tuple
import random
from ipdb import set_trace as st
class BaxterEnv(fakercnn_pusher.BaxterEnv):
def __init__(self, *args, rot = False, rot_scale = 0.2, pos_scale = 0.03, bound = 0.2,
img = Tru... | 4,719 | 32.956835 | 96 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/reacher2d_rel.py | from HER.envs import reacher2d
import numpy as np
class BaxterEnv(reacher2d.BaxterEnv):
def _get_rel_ob(self, absolute_ob):
gripper_pos = absolute_ob[:self.space_dim]
target_pos = absolute_ob[-self.space_dim:]
return np.concatenate((gripper_pos, target_pos - gripper_pos))
def _ge... | 2,123 | 35 | 119 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/close_pusher.py | from HER.envs import pusher
import numpy as np
class BaxterEnv(pusher.BaxterEnv):
def __init__(self, max_len=20, **kwargs):
super(BaxterEnv, self).__init__(max_len = max_len, **kwargs)
self.target_range_min += 0.05
self.target_range_max -= 0.05
def reset_model(self,
# de... | 2,098 | 37.163636 | 105 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/mujoco_env.py | import os
import os.path as osp
import numpy as np
from gym.utils import seeding
import gym
from gym.envs.robotics.utils import reset_mocap2body_xpos, mocap_set_action, reset_mocap_welds
import socket
try:
import mujoco_py
from mujoco_py.mjviewer import MjViewerBasic, MjViewer
except ImportError as e:
rai... | 5,763 | 29.17801 | 178 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/close_pusher_rel.py | from HER.envs import close_pusher
import numpy as np
class BaxterEnv(close_pusher.BaxterEnv):
def __init__(self, max_len=50):
super(BaxterEnv, self).__init__(max_len=max_len)
def _get_rel_ob(self, absolute_ob):
gripper_pos = absolute_ob[:self.space_dim]
object_pos = absolute_ob[s... | 2,285 | 37.745763 | 123 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/bb_pusher.py | from HER.envs import oc_pusher
import numpy as np
import math
import random
from scipy.misc import imsave
from ipdb import set_trace as st
class BaxterEnv(oc_pusher.BaxterEnv):
def __init__(self, bbox_noise = 0.0, *args, **kwargs):
super().__init__(*args, **kwargs)
self.debug = F... | 4,569 | 30.736111 | 114 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/oc_pusher.py | from HER.envs import close_pusher
import numpy as np
from gym import spaces
from ipdb import set_trace as st
from HER.envs.pusher import _tuple, _ndarray
# in oc pusher, simply storing the ground truth location of the box is no longer
# sufficient to recover the reward, because we have neither the estimated box
# loc... | 2,325 | 32.710145 | 90 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/fakercnn_pusher.py | from HER.envs import bb_pusher
import numpy as np
from HER.rcnn import renderer
import random
from keras import backend as K
from HER.rcnn import load_rcnn
import tensorflow as tf
from HER.envs.pusher import _tuple
from ipdb import set_trace as st
class BaxterEnv(bb_pusher.BaxterEnv):
def __init__(self, *args, a... | 4,861 | 32.531034 | 97 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/__init__.py | from gym.envs.registration import register
import HER
register(
id='pusher-v0',
entry_point='HER.envs.pusher:BaxterEnv',
kwargs={'max_len':20}
)
register(
id='pusher-v1',
entry_point='HER.envs.close_pusher:BaxterEnv',
kwargs={'max_len':20}
)
register(
id='oc_pusher-v0',
entry_point='H... | 6,529 | 26.787234 | 90 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/envs/reacher3d.py | import numpy as np
from HER.envs import reacher2d
from gym.envs.robotics.utils import mocap_set_action
class BaxterEnv(reacher2d.BaxterEnv):
"""cts env, 6dim
state space: absolute state space position of gripper, target
random restarts for target on the table
reward function: - 1(not reaching)
acti... | 2,385 | 30.813333 | 136 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/mpi_adam.py | from mpi4py import MPI
import HER.common.tf_util as U
import tensorflow as tf
import numpy as np
class MpiAdam(object):
def __init__(self, var_list, *, beta1=0.9, beta2=0.999, epsilon=1e-08, scale_grad_by_procs=True, comm=None, single_train = False):
self.var_list = var_list
self.beta1 = b... | 3,025 | 33 | 134 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/cg.py | import numpy as np
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"
titlestr = "%10s %10s %10s"
if verbose: print(titlestr % ("iter... | 896 | 25.382353 | 88 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/distributions.py | import tensorflow as tf
import numpy as np
import HER.common.tf_util as U
from tensorflow.python.ops import math_ops
class Pd(object):
"""
A particular probability distribution
"""
def flatparam(self):
raise NotImplementedError
def mode(self):
raise NotImplementedError
def neglo... | 10,914 | 36.12585 | 201 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/schedules.py | """This file is used for specifying various schedules that evolve over
time throughout the execution of the algorithm, such as:
- learning rate for the optimizer
- exploration epsilon for the epsilon greedy exploration strategy
- beta parameter for beta parameter in prioritized replay
Each schedule has a function `... | 3,702 | 36.03 | 90 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/atari_wrappers.py | import numpy as np
from collections import deque
import gym
from gym import spaces
import cv2
class NoopResetEnv(gym.Wrapper):
def __init__(self, env, noop_max=30):
"""Sample initial states by taking random number of no-ops on reset.
No-op is assumed to be action 0.
"""
gym.Wrapper.... | 7,334 | 34.606796 | 97 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/mpi_running_mean_std.py | from mpi4py import MPI
import tensorflow as tf, HER.common.tf_util as U, numpy as np
from HER import logger
class RunningMeanStd(object):
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
def __init__(self, epsilon=1e-2, shape=()):
self._sum = tf.get_variable(
... | 4,429 | 31.814815 | 126 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/azure_utils.py | import os
import tempfile
import zipfile
from azure.common import AzureMissingResourceHttpError
try:
from azure.storage.blob import BlobService
except ImportError:
from azure.storage.blob import BlockBlobService as BlobService
from shutil import unpack_archive
from threading import Event
# TODOS: use Azure sn... | 5,962 | 37.470968 | 91 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/misc_util.py | import gym
import numpy as np
import os
import pickle
import random
import tempfile
import zipfile
def zipsame(*seqs):
L = len(seqs[0])
assert all(len(seq) == L for seq in seqs[1:])
return zip(*seqs)
def unpack(seq, sizes):
"""
Unpack 'seq' into a sequence of lists, with lengths specified by 'si... | 7,550 | 28.267442 | 110 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/mpi_fork.py | import os, subprocess, sys
def mpi_fork(n, bind_to_core=False):
"""Re-launches the current script with workers
Returns "parent" for original parent, "child" for MPI children
"""
if n<=1:
return "child"
if os.getenv("IN_MPI") is None:
env = os.environ.copy()
env.update(
... | 668 | 26.875 | 66 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/dataset.py | import numpy as np
class Dataset(object):
def __init__(self, data_map, deterministic=False, shuffle=True):
self.data_map = data_map
self.deterministic = deterministic
self.enable_shuffle = shuffle
self.n = next(iter(data_map.values())).shape[0]
self._next_id = 0
self... | 2,132 | 33.967213 | 110 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/math_util.py | import numpy as np
import scipy.signal
def discount(x, gamma):
"""
computes discounted sums along 0th dimension of x.
inputs
------
x: ndarray
gamma: float
outputs
-------
y: ndarray with same shape as x, satisfying
y[t] = x[t] + gamma*x[t+1] + gamma^2*x[t+2] + ... + gam... | 2,093 | 23.635294 | 75 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/tf_util.py | import numpy as np
import tensorflow as tf # pylint: ignore-module
import builtins
import functools
import copy
import os
import collections
# ================================================================
# Make consistent with numpy
# ================================================================
clip = tf.cli... | 24,681 | 34.875 | 120 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/running_mean_std.py | import numpy as np
class RunningMeanStd(object):
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
def __init__(self, epsilon=1e-4, shape=()):
self.mean = np.zeros(shape, 'float64')
self.var = np.ones(shape, 'float64')
self.count = epsilon
def u... | 965 | 31.2 | 97 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/segment_tree.py | import operator
class SegmentTree(object):
def __init__(self, capacity, operation, neutral_element):
"""Build a Segment Tree data structure.
https://en.wikipedia.org/wiki/Segment_tree
Can be used as regular array, but with two
important differences:
a) setting item's... | 4,868 | 32.122449 | 109 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/__init__.py | from HER.common.console_util import *
from HER.common.dataset import Dataset
from HER.common.math_util import *
from HER.common.misc_util import *
| 147 | 28.6 | 38 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/mpi_moments.py | from mpi4py import MPI
import numpy as np
from HER.common import zipsame
from HER import logger
def mpi_moments(x, axis=0):
x = np.asarray(x, dtype='float64')
newshape = list(x.shape)
newshape.pop(axis)
n = np.prod(newshape,dtype=int)
totalvec = np.zeros(n*2+1, 'float64')
addvec = np.concatenat... | 1,922 | 29.52381 | 79 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/console_util.py | from __future__ import print_function
from contextlib import contextmanager
import numpy as np
import time
# ================================================================
# Misc
# ================================================================
def fmt_row(width, row, header=False):
out = " | ".join(fmt_item(x... | 1,353 | 23.618182 | 104 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/tests/test_tf_util.py | # tests for tf_util
import tensorflow as tf
from HER.common.tf_util import (
function,
initialize,
set_value,
single_threaded_session
)
def test_set_value():
a = tf.Variable(42.)
with single_threaded_session():
set_value(a, 5)
assert a.eval() == 5
g = tf.get_default_gra... | 1,604 | 21.928571 | 56 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/tests/test_schedules.py | import numpy as np
from HER.common.schedules import ConstantSchedule, PiecewiseSchedule
def test_piecewise_schedule():
ps = PiecewiseSchedule([(-5, 100), (5, 200), (10, 50), (100, 50), (200, -50)], outside_value=500)
assert np.isclose(ps.value(-10), 500)
assert np.isclose(ps.value(0), 150)
assert np... | 817 | 29.296296 | 101 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/tests/test_segment_tree.py | import numpy as np
from HER.common.segment_tree import SumSegmentTree, MinSegmentTree
def test_tree_set():
tree = SumSegmentTree(4)
tree[2] = 1.0
tree[3] = 3.0
assert np.isclose(tree.sum(), 4.0)
assert np.isclose(tree.sum(0, 2), 0.0)
assert np.isclose(tree.sum(0, 3), 1.0)
assert np.iscl... | 2,685 | 24.826923 | 66 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/vec_env/vec_normalize.py | from HER.common.vec_env import VecEnv
from HER.common.running_mean_std import RunningMeanStd
import numpy as np
class VecNormalize(VecEnv):
"""
Vectorized environment base class
"""
def __init__(self, venv, ob=True, ret=True, clipob=10., cliprew=10., gamma=0.99, epsilon=1e-8):
self.venv = venv
... | 3,491 | 32.257143 | 120 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/vec_env/dummy_vec_env.py | import numpy as np
from . import VecEnv
class DummyVecEnv(VecEnv):
def __init__(self, env_fns):
self.envs = [fn() for fn in env_fns]
env = self.envs[0]
self.action_space = env.action_space
self.observation_space = env.observation_space
self.ts = np.zeros(len(self.env... | 933 | 34.923077 | 71 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/vec_env/__init__.py | class VecEnv(object):
"""
Vectorized environment base class
"""
def step(self, vac):
"""
Apply sequence of actions to sequence of environments
actions -> (observations, rewards, news)
where 'news' is a boolean vector indicating whether each element is new.
"""
... | 495 | 25.105263 | 80 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/vec_env/subproc_vec_env.py | import numpy as np
from multiprocessing import Process, Pipe
from HER.common.vec_env import VecEnv
def worker(remote, parent_remote, env_fn_wrapper):
parent_remote.close()
env = env_fn_wrapper.x()
while True:
cmd, data = remote.recv()
if cmd == 'step':
ob, reward, done, info = ... | 2,980 | 30.378947 | 97 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/common/vec_env/vec_frame_stack.py | from HER.common.vec_env import VecEnv
import numpy as np
from gym import spaces
class VecFrameStack(VecEnv):
"""
Vectorized environment base class
"""
def __init__(self, venv, nstack):
self.venv = venv
self.nstack = nstack
wos = venv.observation_space # wrapped ob space
... | 1,681 | 32.64 | 80 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/prun.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.pddpg.training as training
from HER.pddpg.models import Actor, Critic
from HER.pddpg.memory import Memory
from HER.pddpg.noise import *
import gym
i... | 6,427 | 41.289474 | 154 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/manual_grasping_agent.py | import HER.envs
import sys
import gym
from time import sleep
import numpy as np
from ipdb import set_trace
if __name__ == "__main__":
print("Loading %s"%sys.argv[1])
np.set_printoptions(precision=3)
env = gym.make(sys.argv[1])
EVAL_EPISODE = 10
reward_mat = []
try:
action1 ... | 3,183 | 31.161616 | 126 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/run.py | import argparse
import time
import os
import logging
from HER import logger
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.training as training
from HER.ddpg.models import *
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
import tensorflow as tf
... | 7,935 | 38.68 | 144 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/random_agent.py | import HER.envs
import sys
import gym
from time import sleep
import numpy as np
from ipdb import set_trace
if __name__ == "__main__":
print("Loading %s"%sys.argv[1])
np.set_printoptions(precision=3)
env = gym.make(sys.argv[1])
EVAL_EPISODE = 100
reward_mat = []
try:
# ob = ... | 2,895 | 30.478261 | 87 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/manual_reacher_agent.py | import HER.envs
import sys
import gym
from time import sleep
import numpy as np
from ipdb import set_trace
if __name__ == "__main__":
print("Loading %s"%sys.argv[1])
np.set_printoptions(precision=3)
env = gym.make(sys.argv[1])
EVAL_EPISODE = 10
reward_mat = []
try:
# ob = e... | 2,537 | 28.511628 | 90 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/visualize.py | import argparse
import time
import os
import logging
from HER import logger
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.testing as testing
from HER.ddpg.models import *
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
import tensorflow as tf
#... | 5,869 | 34.575758 | 125 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/examples/pvisualize.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.pddpg.testing as testing
from HER.pddpg.models import Actor, Critic
from HER.pddpg.memory import Memory
from HER.pddpg.noise import *
import gym
imp... | 5,011 | 36.684211 | 146 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/load_rcnn.py |
import sys
# /home/ricsonc/hindsight_experience_replay/HER/rcnn/load_rcnn.py
# -> /home/ricsonc/hindsight_experience_replay/HER/rcnn/Mask_RCNN
sys.path.append(__file__.replace('load_rcnn.py', 'Mask_RCNN'))
sys.path.append(__file__.replace('load_rcnn.py', ''))
import os
import sys
import random
import math
import re
... | 1,027 | 23.47619 | 66 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/renderer.py | import numpy as np
from scipy.misc import imsave
from functools import reduce
class Renderer(object):
def __init__(self, env):
self.env = env
self.data = env.sim.data
self.model = env.sim.model
self.is_amodal = self.env.img_params.is_amodal
self.cam = self.env.img_... | 5,179 | 32.205128 | 88 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/train_mujoco.py | import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append('Mask_RCNN')
import os
import sys
import random
import math
import re
import time
import numpy as np
from config import Config
import utils
import model as modellib
from model import log
import large_dataset
class MujocoConfig(Config):
"""Config... | 3,660 | 30.290598 | 77 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/large_dataset.py | import sys
if ('HER/examples/run.py' not in sys.argv[0]) and ('HER/examples/visualize.py' not in sys.argv[0]):
try:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import visualize
except:
print ('import failed')
from Mask_RCN... | 5,478 | 25.990148 | 99 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/toy_train_mujoco.py | import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append('Mask_RCNN')
import os
import sys
import random
import math
import re
import time
import numpy as np
from config import Config
import utils
import model as modellib
from model import log
import mujoco_dataset
class MujocoConfig(Config):
"""Confi... | 3,816 | 30.808333 | 77 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/toy_vis_mujoco.py | import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append('Mask_RCNN')
import os
import sys
import random
import math
import re
import time
import numpy as np
from config import Config
import utils
import model as modellib
from model import log
import visualize
import mujoco_datasetp
from toy_train_mujoco i... | 1,744 | 27.145161 | 87 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/mujoco_dataset.py | import matplotlib
matplotlib.use('Agg')
from Mask_RCNN.utils import Dataset
from renderer import Renderer
import numpy as np
import matplotlib.pyplot as plt
import sys
sys.path.append('Mask_RCNN')
import visualize
from time import time
import pickle
import os
class MujocoData(Dataset):
def __init__(self,... | 3,392 | 24.511278 | 88 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/__init__.py | 0 | 0 | 0 | py | |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/vis_mujoco.py | import matplotlib
matplotlib.use('Agg')
import sys
sys.path.append('Mask_RCNN')
import os
import sys
import random
import math
import re
import time
import numpy as np
from config import Config
import utils
import model as modellib
from model import log
import visualize
import large_dataset
from train_mujoco import ... | 2,015 | 26.243243 | 91 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/parallel_model.py | """
Mask R-CNN
Multi-GPU Support for Keras.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
Ideas and a small code snippets from these sources:
https://github.com/fchollet/keras/issues/2436
https://medium.com/@kuza55/transparent-multi-gpu-training... | 6,863 | 38.448276 | 95 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/utils.py | """
Mask R-CNN
Common utility functions and classes.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""
import sys
import os
import math
import random
import numpy as np
import tensorflow as tf
import scipy.misc
import skimage.color
import skimag... | 26,771 | 35.673973 | 99 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/model.py | """
Mask R-CNN
The main Mask R-CNN model implemenetation.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""
import os
import sys
import glob
import random
import math
import datetime
import itertools
import json
import re
import logging
from col... | 111,322 | 42.553599 | 115 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/config.py | """
Mask R-CNN
Base Configurations class.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""
import math
import numpy as np
# Base Configuration Class
# Don't use this class directly. Instead, sub-class it and override
# the configurations you ... | 6,192 | 35.64497 | 78 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/shapes.py | """
Mask R-CNN
Configurations and data loading code for the synthetic Shapes dataset.
This is a duplicate of the code in the noteobook train_shapes.ipynb for easy
import into other notebooks, such as inspect_model.ipynb.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Writt... | 7,392 | 38.962162 | 79 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/visualize.py | """
Mask R-CNN
Display and Visualization Functions.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
"""
import random
import itertools
import colorsys
import numpy as np
from skimage.measure import find_contours
import matplotlib.pyplot as plt
imp... | 16,690 | 35.845475 | 92 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/rcnn/Mask_RCNN/coco.py | """
Mask R-CNN
Configurations and data loading code for MS COCO.
Copyright (c) 2017 Matterport, Inc.
Licensed under the MIT License (see LICENSE for details)
Written by Waleed Abdulla
------------------------------------------------------------
Usage: import the module (see Jupyter notebooks for examples), or run fr... | 20,737 | 38.880769 | 124 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/main.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.training as training
from HER.ddpg.models import Actor, Critic
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
impor... | 5,677 | 41.691729 | 136 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/visualize_trained_agent.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.testing as testing
from HER.ddpg.models import Actor, Critic
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
import ... | 4,942 | 37.023077 | 136 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/ddpg.py | from copy import copy
from functools import reduce
import numpy as np
import tensorflow as tf
import tensorflow.contrib as tc
from HER import logger
from mpi4py import MPI
from HER.common.mpi_adam import MpiAdam
import HER.common.tf_util as U
from HER.common.mpi_running_mean_std import RunningMeanStd
from HER.ddpg.ut... | 23,267 | 40.924324 | 183 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/temp.py | import gym
env_id = "HalfCheetah-v1"
env = gym.make(env_id)
done = False
env.reset()
while(not done):
a = env.action_space.sample()
_, _, done, _ = env.step(a)
env.render() | 185 | 17.6 | 33 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/memory.py | import numpy as np
class RingBuffer(object):
def __init__(self, maxlen, shape, dtype='float32'):
self.maxlen = maxlen
self.start = 0
self.length = 0
self.data = np.zeros((maxlen,) + shape).astype(dtype)
def __len__(self):
return self.length
def __getitem__(self, i... | 3,721 | 32.836364 | 106 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/training.py | import os
import time
from collections import deque
import pickle
import math
import imageio
from HER.ddpg.ddpg import DDPG
from HER.ddpg.util import normal_mean, normal_std, mpi_max, mpi_sum
import HER.common.tf_util as U
from HER import logger
import numpy as np
import tensorflow as tf
from mpi4py import MPI
impo... | 16,897 | 40.014563 | 192 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/testing.py | import os
import time
from collections import deque
import pickle
import math
from HER.ddpg.ddpg import DDPG
from HER.ddpg.util import mpi_mean, mpi_std, mpi_max, mpi_sum
import HER.common.tf_util as U
from HER import logger
import numpy as np
import tensorflow as tf
from mpi4py import MPI
import os.path as osp
from... | 5,238 | 36.963768 | 184 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/noise.py | import numpy as np
from random import random
class AdaptiveParamNoiseSpec(object):
def __init__(self, initial_stddev=0.1, desired_action_stddev=0.1, adoption_coefficient=1.01):
self.initial_stddev = initial_stddev
self.desired_action_stddev = desired_action_stddev
self.adoption_coefficient ... | 2,883 | 32.929412 | 143 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/util.py | import numpy as np
import tensorflow as tf
from mpi4py import MPI
from HER.common.mpi_moments import mpi_moments
def reduce_var(x, axis=None, keepdims=False):
m = tf.reduce_mean(x, axis=axis, keep_dims=True)
devs_squared = tf.square(x - m)
return tf.reduce_mean(devs_squared, axis=axis, keep_dims=keepdims)... | 1,509 | 24.166667 | 70 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/plot_results_progress.py | import pandas as pd
import matplotlib.pyplot as plt
from sys import argv
import numpy as np
from ipdb import set_trace
if __name__ == "__main__":
dirname = argv[1]
print("checking the dir %s"%dirname)
try:
data = pd.read_csv(dirname + "progress.csv")
data = data.fillna(0.0)
print(data["eval/success"][-10:])
... | 867 | 23.8 | 79 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/custom_op.py | import tensorflow as tf
# Python Custom Gradient Function
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
"""
PyFunc defined as given by Tensorflow
:param func: Custom Function
:param inp: Function Inputs
:param Tout: Ouput Type of out Custom Function
:param stateful: Calcul... | 1,792 | 29.389831 | 102 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/models.py | import tensorflow as tf
import tensorflow.contrib as tc
import tensorflow.contrib.slim as slim
from ipdb import set_trace as st
#the action order is... 2 tr, 2 rt
def convnet(input):
with slim.arg_scope([slim.conv2d, slim.conv2d_transpose],
padding="SAME",
activatio... | 9,108 | 35.436 | 150 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/ddpg/__init__.py | 0 | 0 | 0 | py | |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/bench/benchmarks.py | import os.path as osp
_atari7 = ['BeamRider', 'Breakout', 'Enduro', 'Pong', 'Qbert', 'Seaquest', 'SpaceInvaders']
_atariexpl7 = ['Freeway', 'Gravitar', 'MontezumaRevenge', 'Pitfall', 'PrivateEye', 'Solaris', 'Venture']
_BENCHMARKS = []
def register_benchmark(benchmark):
for b in _BENCHMARKS:
if b['name'... | 5,008 | 36.661654 | 114 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/bench/monitor.py | __all__ = ['Monitor', 'get_monitor_files', 'load_results']
import gym
from gym.core import Wrapper
import time
from glob import glob
import csv
import os.path as osp
import json
class Monitor(Wrapper):
EXT = "monitor.csv"
f = None
def __init__(self, env, filename, allow_early_resets=False, reset_keywords... | 4,551 | 36.00813 | 174 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/bench/__init__.py | from HER.bench.benchmarks import *
from HER.bench.monitor import *
| 67 | 21.666667 | 34 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/main.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.training as training
from HER.ddpg.models import Actor, Critic
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
impor... | 5,771 | 42.398496 | 146 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/visualize_trained_agent.py | import argparse
import time
import os
import logging
from HER import logger, bench
from HER.common.misc_util import (
set_global_seeds,
boolean_flag,
)
import HER.ddpg.testing as testing
from HER.ddpg.models import Actor, Critic
from HER.ddpg.memory import Memory
from HER.ddpg.noise import *
import gym
import ... | 5,036 | 37.746154 | 146 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/ddpg.py | from copy import copy
from functools import reduce
import numpy as np
import tensorflow as tf
import tensorflow.contrib as tc
from HER import logger
from HER.common.mpi_adam import MpiAdam
import HER.common.tf_util as U
from HER.common.mpi_running_mean_std import RunningMeanStd
from HER.ddpg.util import reduce_std, m... | 18,516 | 44.720988 | 183 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/temp.py | import gym
env_id = "HalfCheetah-v1"
env = gym.make(env_id)
done = False
env.reset()
while(not done):
a = env.action_space.sample()
_, _, done, _ = env.step(a)
env.render() | 185 | 17.6 | 33 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/memory.py | import numpy as np
class RingBuffer(object):
def __init__(self, maxlen, shape, dtype='float32'):
self.maxlen = maxlen
self.start = 0
self.length = 0
self.data = np.zeros((maxlen,) + shape).astype(dtype)
def __len__(self):
return self.length
def __getitem__(self, i... | 2,724 | 31.440476 | 84 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/training.py | import os
import time
from collections import deque
import pickle
import math
from HER.ddpg.ddpg import DDPG
from HER.ddpg.util import normal_mean, normal_std, mpi_max, mpi_sum
import HER.common.tf_util as U
from HER import logger
import numpy as np
import tensorflow as tf
from mpi4py import MPI
import os.path as o... | 14,408 | 42.01194 | 192 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/testing.py | import os
import time
from collections import deque
import pickle
import math
from HER.ddpg.ddpg import DDPG
from HER.ddpg.util import mpi_mean, mpi_std, mpi_max, mpi_sum
import HER.common.tf_util as U
from HER import logger
import numpy as np
import tensorflow as tf
from mpi4py import MPI
import os.path as osp
from... | 3,764 | 37.814433 | 184 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/noise.py | import numpy as np
from random import random
class AdaptiveParamNoiseSpec(object):
def __init__(self, initial_stddev=0.1, desired_action_stddev=0.1, adoption_coefficient=1.01):
self.initial_stddev = initial_stddev
self.desired_action_stddev = desired_action_stddev
self.adoption_coefficient ... | 2,883 | 32.929412 | 143 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/util.py | import numpy as np
import tensorflow as tf
from mpi4py import MPI
from HER.common.mpi_moments import mpi_moments
def reduce_var(x, axis=None, keepdims=False):
m = tf.reduce_mean(x, axis=axis, keep_dims=True)
devs_squared = tf.square(x - m)
return tf.reduce_mean(devs_squared, axis=axis, keep_dims=keepdims)... | 1,509 | 24.166667 | 70 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/plot_results_progress.py | import pandas as pd
import matplotlib.pyplot as plt
from sys import argv
import numpy as np
from ipdb import set_trace
if __name__ == "__main__":
dirname = argv[1]
print("checking the dir %s"%dirname)
try:
data = pd.read_csv(dirname + "progress.csv")
data = data.fillna(0.0)
print(data["eval/success"][-10:])
... | 866 | 23.771429 | 79 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/custom_op.py | import tensorflow as tf
# Python Custom Gradient Function
def py_func(func, inp, Tout, stateful=True, name=None, grad=None):
"""
PyFunc defined as given by Tensorflow
:param func: Custom Function
:param inp: Function Inputs
:param Tout: Ouput Type of out Custom Function
:param stateful: Calcul... | 1,792 | 29.389831 | 102 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/models.py | import tensorflow as tf
import tensorflow.contrib as tc
class Model(object):
def __init__(self, name):
self.name = name
@property
def vars(self):
return tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope=self.name)
@property
def trainable_vars(self):
return tf.get_col... | 2,919 | 33.761905 | 147 | py |
ActiveVisionManipulation | ActiveVisionManipulation-master/HER/pddpg/__init__.py | 0 | 0 | 0 | py | |
hepdata-converter | hepdata-converter-master/setup.py | # -*- coding: utf-8 -*-
"Library providing means of conversion between oldhepdata format to new one, and new one to csv / yoda / root etc."
import os
from setuptools import setup
import re
def get_all_datafiles(package, path):
r = []
setup_path = os.path.dirname(__file__)
for abs_path, dirs, files in os... | 1,868 | 29.145161 | 124 | py |
hepdata-converter | hepdata-converter-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# This file is part of HEPData.
# Copyright (C) 2016 CERN.
#
# HEPData is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later... | 10,885 | 30.645349 | 105 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/version.py | # this file ideally should only contain __version__ declaration, as anything else
# may break setup.py and PyPI uploads
__version__ = '0.2.3'
| 142 | 34.75 | 81 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/common.py | import inspect
import textwrap
class Option(object):
def __init__(self, name, shortversion=None, type=str, default=None, variable_mapping=None, required=True, help='', auto_help=True):
self.name = name
self.help = help
self.required = required
self.auto_help = auto_help
sel... | 4,317 | 32.734375 | 135 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/__init__.py | from io import StringIO
import argparse
import sys
from . import version
from hepdata_validator import LATEST_SCHEMA_VERSION
from .parsers import Parser
from .writers import Writer
def convert(input, output=None, options={}):
"""Converts a supported ``input_format`` (*oldhepdata*, *yaml*)
to a supported ``out... | 4,394 | 37.552632 | 185 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/csv_writer.py | import copy
import csv
from hepdata_converter.common import Option
from hepdata_converter.writers.array_writer import ArrayWriter
class CSV(ArrayWriter):
help = 'Writes to CSV format, it can write either one table (specified by --table parameter) or all tables from the ' \
'input file. In the case of o... | 5,704 | 45.762295 | 141 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/yoda_writer.py | from hepdata_converter.common import Option
from hepdata_converter.writers.array_writer import ArrayWriter, ObjectWrapper, ObjectFactory
import yoda, yaml
class ScatterYodaClass(ObjectWrapper):
dim = -1
_scatter_classes = [yoda.core.Scatter1D, yoda.core.Scatter2D, yoda.core.Scatter3D]
_point_classes = [yo... | 5,728 | 36.444444 | 116 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/utils.py | def error_value_processor(value, error):
"""
If an error is a percentage, we convert to a float, then
calculate the percentage of the supplied value.
:param value: base value, e.g. 10
:param error: e.g. 20.0%
:return: the absolute error, e.g. 12 for the above case.
"""
if isinstance(err... | 683 | 27.5 | 60 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/__init__.py | import inspect
import os
import pkgutil
from hepdata_converter.common import GetConcreteSubclassMixin, OptionInitMixin
__all__ = []
import abc
class Writer(GetConcreteSubclassMixin, OptionInitMixin, metaclass=abc.ABCMeta):
def __init__(self, single_file_output, *args, **kwargs):
OptionInitMixin.__init__... | 1,569 | 32.404255 | 113 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/yaml_writer.py | import yaml
# We try to dump using the CSafeDumper for speed improvements.
try:
from yaml import CSafeDumper as Dumper
except ImportError: #pragma: no cover
from yaml import SafeDumper as Dumper #pragma: no cover
from hepdata_converter.common import Option, OptionInitMixin
from hepdata_converter.writers import ... | 3,048 | 43.838235 | 137 | py |
hepdata-converter | hepdata-converter-master/hepdata_converter/writers/array_writer.py | import logging
from math import sqrt
import os
from hepdata_converter.common import Option
from hepdata_converter.writers import Writer
import abc
from hepdata_converter.writers.utils import error_value_processor
logging.basicConfig()
log = logging.getLogger(__name__)
class ObjectWrapper(object, metaclass=abc.ABCMeta... | 17,598 | 41.509662 | 170 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.