class_docstr: Implements a recurrent DQN designed to produce melody sequences.
class_docstr_tok: ["Implements","a","recurrent","DQN","designed","to","produce","melody","sequences","."]
docstr: Restores this model from a saved checkpoint.
  
  Args:
    directory: Path to directory where checkpoint is located. If
      None, defaults to self.output_dir.
    checkpoint_name: The name of the checkpoint within the
      directory.
    reward_file_name: The name of the .npz file where the stored
      rewards are saved. If None, will not attempt to load stored
      rewards.
docstr_tok: ["Restores","this","model","from","a","saved","checkpoint",".","Args",":","directory",":","Path","to","directory","where","checkpoint","is","located",".","If","None",",","defaults","to","self.output_dir",".","checkpoint_name",":","The","name","of","the","checkpoint","within","the","directory",".","reward_file_name",":","The","name","of","the",".npz","file","where","the","stored","rewards","are","saved",".","If","None",",","will","not","attempt","to","load","stored","rewards","."]
code: def restore_from_directory(
      self, directory=None, checkpoint_name=None, reward_file_name=None
  ):
      """Restores this model from a saved checkpoint.
  
      Args:
        directory: Path to directory where checkpoint is located. If
          None, defaults to self.output_dir.
        checkpoint_name: The name of the checkpoint within the
          directory.
        reward_file_name: The name of the .npz file where the stored
          rewards are saved. If None, will not attempt to load stored
          rewards.
      """
      if directory is None:
          directory = self.output_dir
  
      if checkpoint_name is not None:
          checkpoint_file = os.path.join(directory, checkpoint_name)
      else:
          tf.logging.info("Directory %s.", directory)
          checkpoint_file = tf.train.latest_checkpoint(directory)
  
      if checkpoint_file is None:
          tf.logging.fatal(
              "Error! Cannot locate checkpoint in the directory"
          )
          return
      # TODO(natashamjaques): Remove print statement once tf.logging outputs
      # to Jupyter notebooks (once the following issue is resolved:
      # https://github.com/tensorflow/tensorflow/issues/3047)
      print("Attempting to restore from checkpoint", checkpoint_file)
      tf.logging.info(
          "Attempting to restore from checkpoint %s", checkpoint_file
      )
  
      self.saver.restore(self.session, checkpoint_file)
  
      if reward_file_name is not None:
          npz_file_name = os.path.join(directory, reward_file_name)
          # TODO(natashamjaques): Remove print statement once tf.logging outputs
          # to Jupyter notebooks (once the following issue is resolved:
          # https://github.com/tensorflow/tensorflow/issues/3047)
          print(
              "Attempting to load saved reward values from file",
              npz_file_name,
          )
          tf.logging.info(
              "Attempting to load saved reward values from file %s",
              npz_file_name,
          )
          npz_file = np.load(npz_file_name)
  
          self.rewards_batched = npz_file["train_rewards"]
          self.music_theory_rewards_batched = npz_file[
              "train_music_theory_rewards"
          ]
          self.note_rnn_rewards_batched = npz_file[
              "train_note_rnn_rewards"
          ]
          self.eval_avg_reward = npz_file["eval_rewards"]
          self.eval_avg_music_theory_reward = npz_file[
              "eval_music_theory_rewards"
          ]
          self.eval_avg_note_rnn_reward = npz_file[
              "eval_note_rnn_rewards"
          ]
          self.target_val_list = npz_file["target_val_list"]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import os
  import random
  import urllib
  from magenta.models.rl_tuner import note_rnn_loader
  from magenta.models.rl_tuner import rl_tuner_eval_metrics
  from magenta.models.rl_tuner import rl_tuner_ops
  import matplotlib.pyplot
  from note_seq import melodies_lib
  from note_seq import midi_io
  import numpy
  import scipy.special
  from six.moves import range
  from six.moves import reload_module
  from six.moves import urllib
  import tensorflow.compat.v1
label_desc: Use image node_id 47 for calling the RLTuner obj's underlying member method code with example usage: obj.restore_from_directory(directory, checkpoint_name, reward_file_name) without return types