class_docstr: Tensorforce agent interface.
class_docstr_tok: ["Tensorforce","agent","interface","."]
docstr: Restores the agent from a checkpoint.
  
  Args:
      directory (str): Checkpoint directory
          (<span style="color:#C00000"><b>required</b></span>).
      filename (str): Checkpoint filename, with or without append and extension
          (<span style="color:#00C000"><b>default</b></span>: agent name).
      format ("checkpoint" | "numpy" | "hdf5"): File format
          (<span style="color:#00C000"><b>default</b></span>: format matching directory and
          filename, required to be unambiguous).
docstr_tok: ["Restores","the","agent","from","a","checkpoint",".","Args",":","directory","(","str",")",":","Checkpoint","directory","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","filename","(","str",")",":","Checkpoint","filename",",","with","or","without","append","and","extension","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","agent","name",")",".","format","(","``","checkpoint","''","|","``","numpy","''","|","``","hdf5","''",")",":","File","format","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","format","matching","directory","and","filename",",","required","to","be","unambiguous",")","."]
code: def restore(self, directory=None, filename=None, format=None):
      """
      Restores the agent from a checkpoint.
  
      Args:
          directory (str): Checkpoint directory
              (<span style="color:#C00000"><b>required</b></span>).
          filename (str): Checkpoint filename, with or without append and extension
              (<span style="color:#00C000"><b>default</b></span>: agent name).
          format ("checkpoint" | "numpy" | "hdf5"): File format
              (<span style="color:#00C000"><b>default</b></span>: format matching directory and
              filename, required to be unambiguous).
      """
      if not hasattr(self, "model"):
          raise TensorforceError(
              message="Missing agent attribute model."
          )
  
      if not self.is_initialized:
          self.initialize()
  
      if filename is None:
          filename = self.model.name
  
      # format implicitly given if file exists
      if format is None and os.path.isfile(
          os.path.join(directory, filename)
      ):
          if ".data-" in filename:
              filename = filename[: filename.index(".data-")]
              format = "checkpoint"
          elif filename.endswith(".npz"):
              filename = filename[:-4]
              format = "numpy"
          elif filename.endswith(".hdf5"):
              filename = filename[:-5]
              format = "hdf5"
          elif filename.endswith(".h5"):
              filename = filename[:-3]
              format = "hdf5"
          else:
              assert False
      elif format is None and os.path.isfile(
          os.path.join(directory, filename + ".index")
      ):
          format = "checkpoint"
      elif format is None and os.path.isfile(
          os.path.join(directory, filename + ".npz")
      ):
          format = "numpy"
      elif format is None and (
          os.path.isfile(os.path.join(directory, filename + ".hdf5"))
          or os.path.isfile(os.path.join(directory, filename + ".h5"))
      ):
          format = "hdf5"
  
      else:
          # infer format from directory
          found = None
          latest = -1
          for name in os.listdir(directory):
              if (
                  format in (None, "numpy")
                  and name == filename + ".npz"
              ):
                  assert found is None
                  found = "numpy"
                  latest = None
              elif (
                  format in (None, "numpy")
                  and name.startswith(filename)
                  and name.endswith(".npz")
              ):
                  assert found is None or found == "numpy"
                  found = "numpy"
                  n = int(name[len(filename) + 1 : -4])
                  if n > latest:
                      latest = n
              elif format in (None, "hdf5") and (
                  name == filename + ".hdf5" or name == filename + ".h5"
              ):
                  assert found is None
                  found = "hdf5"
                  latest = None
              elif (
                  format in (None, "hdf5")
                  and name.startswith(filename)
                  and (name.endswith(".hdf5") or name.endswith(".h5"))
              ):
                  assert found is None or found == "hdf5"
                  found = "hdf5"
                  n = int(name[len(filename) + 1 : -5])
                  if n > latest:
                      latest = n
  
          if latest == -1:
              if format is None:
                  format = "checkpoint"
              else:
                  assert format == "checkpoint"
              if not os.path.isfile(
                  os.path.join(directory, filename + ".index")
              ):
                  import tensorflow as tf
  
                  path = tf.train.latest_checkpoint(
                      checkpoint_dir=directory
                  )
                  if not path:
                      raise TensorforceError.exists_not(
                          name="Checkpoint", value=directory
                      )
                  _directory, filename = os.path.split(path)
                  assert _directory == directory
  
          else:
              if format is None:
                  format = found
              else:
                  assert format == found
              if latest is not None:
                  filename = filename + "-" + str(latest)
  
      self.timesteps, self.episodes, self.updates = self.model.restore(
          directory=directory, filename=filename, format=format
      )
  
imports: from collections import OrderedDict
  import json
  import logging
  import os
  import random
  import numpy
  import tensorflow
  from tensorforce import util, TensorforceError
  from tensorforce.agents import Recorder
  import tensorforce.agents
  from tensorforce.core import ArrayDict, TensorSpec, TensorforceConfig
label_desc: Use image node_id 16 for calling the Agent obj's underlying member method code with example usage: obj.restore(directory, filename, format) without return types