google / dopamine

Dopamine is a research framework for fast prototyping of reinforcement learning algorithms.
https://github.com/google/dopamine
Apache License 2.0
10.42k stars 1.36k forks source link

How to load checkpoint as an independent TF/Keras model for utilizing? #136

Open xinghua-qu opened 4 years ago

xinghua-qu commented 4 years ago

Hi,

Is there any example code about how to load the checkpoint (https://github.com/google/dopamine/tree/master/docs#downloads) that can be utilized independently? For instance, I use openAI gym to create an environment and utilize your checkpoint model to predict actions.

Many thanks and stay safe.

nhewitt99 commented 3 years ago

I've been working on the same thing. Try this, changing the paths and the "24" (the iteration checkpoint to use) as necessary:

import tensorflow.compat.v1 as tf
with tf.Session() as sess:
    saver = tf.train.import_meta_graph('{path/to/base/dir}/checkpoints/tf_ckpt-24.meta', clear_devices=True)
    saver.restore(sess, tf.train.latest_checkpoint('{path/to/base/dir}/checkpoints'))

Using Dopamine is my first trial-by-fire with Tensorflow, so I'm not sure of meaningful next steps yet after opening the session, but hopefully this first step can help you some.