def load(path, num_cpus=1): with open(path, "rb") as f: model_data, act_params = dill.load(f) act = build_act(**act_params) sess = U.make_session(num_cpus=num_cpus) sess.__enter__() with tempfile.TemporaryDirectory() as td: filepath = os.path.join(td, "packed.zip") with open(filepath, "wb") as f: f.write(model_data) zipfile.ZipFile(filepath, 'r', zipfile.ZIP_DEFLATED).extractall(td) U.load_state(os.path.join(td, "model")) return ActWrapper(act, act_params)
def load(path): with open(path, "rb") as f: model_data, act_params = cloudpickle.load(f) act = build_act(**act_params) with tempfile.TemporaryDirectory() as td: arc_path = os.path.join(td, "packed.zip") with open(arc_path, "wb") as f: f.write(model_data) zipfile.ZipFile(arc_path, 'r', zipfile.ZIP_DEFLATED).extractall(td) load_state(os.path.join(td, "model")) return ActWrapper(act, act_params)
def load(path): with open(path, "rb") as f: model_data, act_params, priorities, actions_num, flat_dv = cloudpickle.load(f) gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=GPU_FRACTION) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) sess.__enter__() act = dict() for ob in priorities: act[ob] = dqn_dv.build_act(**act_params[ob]) with tempfile.TemporaryDirectory() as td: arc_path = os.path.join(td, "packed.zip") with open(arc_path, "wb") as f: f.write(model_data) zipfile.ZipFile(arc_path, 'r', zipfile.ZIP_DEFLATED).extractall(td) U.load_state(os.path.join(td, "model")) return MultiActWrapper(act, act_params, priorities, actions_num, flat_dv)