(self)
Primes the model with its default midi primer.
Primes the model with its default midi primer.
Primes the model with its default midi primer .
def prime_model(self):
    """Primes the model with its default midi primer."""
    with self.graph.as_default():
      tf.logging.debug('Priming the model with MIDI file %s', self.midi_primer)

      # Convert primer Melody to model inputs.
      encoder = note_seq.OneHotEventSequenceEncoderDecoder(
          note_seq.MelodyOneHotEncoding(
              min_note=rl_tuner_ops.MIN_NOTE, max_note=rl_tuner_ops.MAX_NOTE))

      primer_input, _ = encoder.encode(self.primer)

      # Run model over primer sequence.
      primer_input_batch = np.tile([primer_input], (self.batch_size, 1, 1))
      self.state_value, softmax = self.session.run(
          [self.state_tensor, self.softmax],
          feed_dict={self.initial_state: self.state_value,
                     self.melody_sequence: primer_input_batch,
                     self.lengths: np.full(self.batch_size,
                                           len(self.primer),
                                           dtype=int)})
      priming_output = softmax[-1, :]
      self.priming_note = self.get_note_from_softmax(priming_output)
def prime_model ( self ) : with self . graph . as_default ( ) : tf . logging . debug ( 'Priming the model with MIDI file %s' , self . midi_primer ) # Convert primer Melody to model inputs. encoder = note_seq . OneHotEventSequenceEncoderDecoder ( note_seq . MelodyOneHotEncoding ( min_note = rl_tuner_ops . MIN_NOTE , max_note = rl_tuner_ops . MAX_NOTE ) ) primer_input , _ = encoder . encode ( self . primer ) # Run model over primer sequence. primer_input_batch = np . tile ( [ primer_input ] , ( self . batch_size , 1 , 1 ) ) self . state_value , softmax = self . session . run ( [ self . state_tensor , self . softmax ] , feed_dict = { self . initial_state : self . state_value , self . melody_sequence : primer_input_batch , self . lengths : np . full ( self . batch_size , len ( self . primer ) , dtype = int ) } ) priming_output = softmax [ - 1 , : ] self . priming_note = self . get_note_from_softmax ( priming_output )