class_docstr: Tensorforce agent interface.
class_docstr_tok: ["Tensorforce","agent","interface","."]
docstr: Initializes the agent. Automatically triggered as part of Agent.create/load.
docstr_tok: ["Initializes","the","agent",".","Automatically","triggered","as","part","of","Agent.create\/load","."]
code: def initialize(self):
      """
      Initializes the agent. Automatically triggered as part of Agent.create/load.
      """
      super().initialize()
  
      # Initialize model
      if not hasattr(self, "model"):
          raise TensorforceError.required_attribute(
              name="Agent", attribute="model"
          )
      self.model.initialize()
  
      # Value space specifications
      assert self.states_spec == self.model.states_spec
      self.internals_spec = self.model.internals_spec
      self.auxiliaries_spec = self.model.auxiliaries_spec
      assert self.actions_spec == self.model.actions_spec
      assert self.terminal_spec == self.model.terminal_spec
      assert self.reward_spec == self.model.reward_spec
      assert self.parallel_spec == self.model.parallel_spec
      self.deterministic_spec = self.model.deterministic_spec
  
      # Parallel observe buffers
      self.terminal_buffer = [
          list() for _ in range(self.parallel_interactions)
      ]
      self.reward_buffer = [
          list() for _ in range(self.parallel_interactions)
      ]
  
      # Store agent spec as JSON
      if self.model.saver is not None:
          path = os.path.join(
              self.model.saver_directory,
              self.model.saver_filename + ".json",
          )
          try:
              with open(path, "w") as fp:
                  spec = OrderedDict(self.spec)
                  spec["internals"] = self.internals_spec
                  spec["initial_internals"] = self.initial_internals()
                  json.dump(obj=spec, fp=fp, cls=TensorforceJSONEncoder)
          except BaseException:
              try:
                  with open(path, "w") as fp:
                      spec = OrderedDict()
                      spec["states"] = self.spec["states"]
                      spec["actions"] = self.spec["actions"]
                      spec["internals"] = self.internals_spec
                      spec[
                          "initial_internals"
                      ] = self.initial_internals()
                      json.dump(
                          obj=spec, fp=fp, cls=TensorforceJSONEncoder
                      )
              except BaseException:
                  os.remove(path)
                  raise
  
      # Reset model
      timesteps, episodes, updates = self.model.reset()
      self.timesteps = timesteps.numpy().item()
      self.episodes = episodes.numpy().item()
      self.updates = updates.numpy().item()
  
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 7 for calling the Agent obj's underlying member method code with example usage: obj.initialize() without return types