GithubHelp home page GithubHelp logo

Comments (10)

peabody124 avatar peabody124 commented on August 16, 2024

For what it is worth, I'm working on a new environment that creates a simple quadcopter model and allows learning to fly this.

screen shot 2017-07-28 at 9 24 17 am

I'm not sure if it would be of interest to contribute.

from roboschool.

olegklimov avatar olegklimov commented on August 16, 2024

Hi @peabody124. These files exported directly by learning tool. You can tell by the difference in -v0 and -v1 we're working on tools as well. No special script to do this.

from roboschool.

peabody124 avatar peabody124 commented on August 16, 2024

@olegklimov which learning tool, or is this something not released? for example the graphs for flag runner harder say they are using PPO. This algorithm from baselines is working fairly well in my environments, but I'm not exactly sure how to dump the parameters from the MlpPolicy into a script like that which can be executed to reload the weights.

from roboschool.

olegklimov avatar olegklimov commented on August 16, 2024

Oh, from baselines is really straightforward to export this.

from roboschool.

peabody124 avatar peabody124 commented on August 16, 2024

@olegklimov any hints or links? :)

from roboschool.

olegklimov avatar olegklimov commented on August 16, 2024

Yeah, sure.

def recursive_np_array_print(a, idx):
    if len(idx)==len(a.shape)-1:
        return "[" + ",".join(["%+8.4f" % a[tuple(idx + [i])] for i in range(a.shape[len(idx)]) ]) + "]"
    else:
        return "[\n" + ",\n".join([recursive_np_array_print(a, idx + [i]) for i in range(a.shape[len(idx)]) ]) + "\n]"

from roboschool.

peabody124 avatar peabody124 commented on August 16, 2024

For what it is worth, this was what I ultimately used to dump from a PPO MlpPolicy to create the weights file

model_meta_fn = 'FILENAME.cpkt.meta'

import tensorflow as tf
sess = tf.Session()
saver = tf.train.import_meta_graph(model_meta_fn)
saver.restore(sess, tf.train.latest_checkpoint('.'))
graph = tf.get_default_graph()

print("Model loaded")

def get_var_by_name(desired):
	return [v for v in tf.global_variables() if v.name == desired][0]


state_mean = get_var_by_name('pi/obfilter/runningsum:0') / get_var_by_name('pi/obfilter/count:0')
state_std = tf.sqrt(tf.maximum(get_var_by_name('pi/obfilter/runningsumsq:0') / get_var_by_name('pi/obfilter/count:0') - tf.square(state_mean), 1e-2))
policy = {  'state_means': sess.run(state_mean),
			'state_std': sess.run(state_std),
			'w0': sess.run(get_var_by_name('pi/polfc1/w:0')),
			'b0': sess.run(get_var_by_name('pi/polfc1/b:0')),
			'w1': sess.run(get_var_by_name('pi/polfc2/w:0')),
			'b1': sess.run(get_var_by_name('pi/polfc2/b:0')),
			'w2': sess.run(get_var_by_name('pi/polfinal/w:0')),
			'b2': sess.run(get_var_by_name('pi/polfinal/b:0'))
		  }

def recursive_np_array_print(a, idx):
	if len(idx)==len(a.shape)-1:
		return "[" + ",".join(["%+8.4f" % a[tuple(idx + [i])] for i in range(a.shape[len(idx)]) ]) + "]"
	else:
		return "[\n" + ",\n".join([recursive_np_array_print(a, idx + [i]) for i in range(a.shape[len(idx)]) ]) + "\n]"

str = "import numpy as np\n"
for key in policy:
	str += key + " = np.array(" + recursive_np_array_print(policy[key], []) + ")\n"

file = open('model.weights', "w")
file.write(str)
file.close()

print("Policy weights dumped to model.weights")

from roboschool.

wenyijiang avatar wenyijiang commented on August 16, 2024

Hi! @peabody124
In the agent_zoo directory there are some files about weights. I want to use my weights that trained by the tensorflow about baselines.ddpg algorithm but there are some issues. I want to know whether I can change my weights file and load it .and how did you do that?
Thanks a lot !!!

from roboschool.

wenyijiang avatar wenyijiang commented on August 16, 2024

@peabody124 I run the code above and change my model file 'model.ckpt.meta' to 'model.weights' . My model is from ddpg algorithm .But there are some issues :
state_mean = get_var_by_name('pi/obfilter/runningsum:0') / get_var_by_name('pi/obfilter/count:0')
return [v for v in tf.global_variables() if v.name == desired][0] IndexError:list index out of range
Could you please tell me the reason and how to modify It ?
Thanks a lot !!

from roboschool.

charles-blouin avatar charles-blouin commented on August 16, 2024

Hi @peabody124 . Would would mind making the quadcopter model available? I would really appreciate! I was digging in the c++ python bullet binding to find a function to apply a pure force or a torque to a robot in roboschool, but I could not find anything. Did I miss something?

from roboschool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.