Example #1
0
    def __init__(self, env, scope=None, **kwargs):
        self.obs_shape = env.obs_shape
        *other, self.image_height, self.image_width, self.image_depth = self.obs_shape
        self.n_frames = other[0] if other else 0
        self.network = cfg.build_network(env, self, scope="network")

        super(Updater, self).__init__(env, scope=scope, **kwargs)
Example #2
0

class Updater:
    pass


updater = Updater()

sess = tf.Session()

with config:
    with sess.as_default():
        if hasattr(cfg, 'prepare_func'):
            cfg.prepare_func()

        network = cfg.build_network(env, updater, scope="network")

        inputs = dict(image=tf.placeholder(tf.float32, (None, *image_shape)), )

        network_outputs = network(inputs, is_training=False)
        network_tensors = network_outputs["tensors"]

        # maybe load weights
        if load_path:
            # variables = {v.name: v for v in trainable_variables("", for_opt=False)}
            # saver = tf.train.Saver(variables)
            saver = tf.train.Saver()
            saver.restore(tf.get_default_session(),
                          os.path.realpath(load_path))

        tf.train.get_or_create_global_step()