Skip to content

Commit

Permalink
Save state
Browse files Browse the repository at this point in the history
  • Loading branch information
kidzik committed Nov 20, 2016
1 parent 22739a9 commit 7324c31
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
21 changes: 10 additions & 11 deletions osim/env/osim.py
Expand Up @@ -52,17 +52,16 @@ class OsimEnv(object):
ninput = 0
noutput = 0

# def __getstate__(self):
# state = self.__dict__.copy()
# del state['osim_model']
# print ("HERE1")
# return state

# def __setstate__(self, newstate):
# self.__dict__.update(newstate)
# self.osim_model = Osim(self.model_path, self.visualize)
# print ("HERE2")
# self.configure()
def __getstate__(self):
state = self.__dict__.copy()
del state['osim_model']
print ("HERE1")
return state

def __setstate__(self, newstate):
self.__dict__.update(newstate)
self.osim_model = Osim(self.model_path, True)
self.configure()

def angular_dist(self, t,s):
x = (t-s) % (2*math.pi)
Expand Down
1 change: 0 additions & 1 deletion scripts/keras-rl/train.ddpg.py
Expand Up @@ -36,7 +36,6 @@
env = ArmEnv(args.visualize)

nb_actions = env.action_space.shape[0]
print (env.observation_space.shape)

# Next, we build a very simple model.
actor = Sequential()
Expand Down
9 changes: 1 addition & 8 deletions tests/test.py → scripts/rllab/visualize.py
@@ -1,23 +1,16 @@
from env.arm import ArmEnv
from env.human import HopEnv, GaitEnv, StandEnv, CrouchEnv
from osim.env import ArmEnv, HopEnv, GaitEnv, StandEnv, CrouchEnv
import joblib
import argparse

from rllab.envs.box2d.cartpole_env import CartpoleEnv
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import stub, run_experiment_lite
# from rllab.exploration_strategies.ou_strategy import OUStrategy
# from rllab.policies.deterministic_mlp_policy import DeterministicMLPPolicy
# from rllab.q_functions.continuous_mlp_q_function import ContinuousMLPQFunction

parser = argparse.ArgumentParser(description='Test a policy')
parser.add_argument('-p', action="store", dest="params_file")
parsed = parser.parse_args()

# fname = "/home/lukasz/workspace/rllab/data/local/experiment/experiment_2016_11_18_15_36_08_0001/params.pkl"
# fname = "/home/lukasz/workspace/rllab/data/local/experiment/experiment_2016_11_16_21_55_28_0001/params.pkl"
# fname = "/home/lukasz/workspace/rllab/data/local/experiment/experiment_2016_11_19_11_18_14_0001/params.pkl"
params = joblib.load(parsed.params_file)
env = params['env']
env.test = True
Expand Down

0 comments on commit 7324c31

Please sign in to comment.