Returns a batch of sequences.

    Returns:
      obs: np.int32 array of size [Time, Batch]
      target: np.int32 array of size [Time, Batch]
763359
def _get_batch(self):
    
    batch_indices = np.mod(
        np.array([
            np.arange(head_index, head_index + self._num_steps + 1) for
            head_index in self._head_indices]),
        self._n_flat_elements)

    obs = np.array([
        self._flat_data[indices[:self._num_steps]]
        for indices in batch_indices]).T
    target = np.array([
        self._flat_data[indices[1:self._num_steps + 1]]
        for indices in batch_indices]).T

    if self._random_sampling:
      self._reset_head_indices()
    else:
      self._head_indices = np.mod(
          self._head_indices + self._num_steps, self._n_flat_elements)
    return obs, target
1267331
def _get_batches(self, items):
        """"""
        for i in xrange(0, len(items), self.max_batch_size):
            yield items[i:i + self.max_batch_size]
1244404
def update(self, mini_batch, num_sequences):
        

        feed_dict = {self.model.dropout_rate: self.update_rate,
                     self.model.batch_size: num_sequences,
                     self.model.sequence_length: self.sequence_length}
        if self.use_continuous_act:
            feed_dict[self.model.true_action] = mini_batch['actions']. \
                reshape([-1, self.brain.vector_action_space_size[0]])
        else:
            feed_dict[self.model.true_action] = mini_batch['actions'].reshape(
                [-1, len(self.brain.vector_action_space_size)])
            feed_dict[self.model.action_masks] = np.ones(
                (num_sequences, sum(self.brain.vector_action_space_size)))
        if self.use_vec_obs:
            apparent_obs_size = self.brain.vector_observation_space_size * \
                                self.brain.num_stacked_vector_observations
            feed_dict[self.model.vector_in] = mini_batch['vector_obs'] \
                .reshape([-1,apparent_obs_size])
        for i, _ in enumerate(self.model.visual_in):
            visual_obs = mini_batch['visual_obs%d' % i]
            feed_dict[self.model.visual_in[i]] = visual_obs
        if self.use_recurrent:
            feed_dict[self.model.memory_in] = np.zeros([num_sequences, self.m_size])
        run_out = self._execute_model(feed_dict, self.update_dict)
        return run_out
969953
def get_dict_to_print(field_to_obs):
  

  def compressed_steps(steps):
    return {'num_steps': len(set(steps)),
            'min_step': min(steps),
            'max_step': max(steps),
            'last_step': steps[-1],
            'first_step': steps[0],
            'outoforder_steps': get_out_of_order(steps)}

  def full_steps(steps):
    return {'steps': steps, 'outoforder_steps': get_out_of_order(steps)}

  output = {}
  for field, observations in field_to_obs.items():
    if not observations:
      output[field] = None
      continue

    steps = [x['step'] for x in observations]
    if field in SHORT_FIELDS:
      output[field] = compressed_steps(steps)
    if field in LONG_FIELDS:
      output[field] = full_steps(steps)

  return output
301560
def sequence(self):
        
        s = scenarios.Scenarios([self.config])
        matrix = s._get_matrix()

        try:
            return matrix[self.name][self.config.subcommand]
        except KeyError:
            # TODO(retr0h): May change this handling in the future.
            return []
614978
def batch_encode(self, iterator, *args, **kwargs):
        
        return [self.encode(object_, *args, **kwargs) for object_ in iterator]
1092479
def fluent_shape(self) -> Sequence[int]:
        ''''''
        return tuple(self._shape.as_list()[1:] if self._batch else self._shape.as_list()[:])
1239763
def to_array(self):
        
        values = numpy.empty(13, dtype=float)
        values[:6] = self.firstdate.to_array()
        values[6:12] = self.lastdate.to_array()
        values[12] = self.stepsize.seconds
        return values
230181
def sequenceToWord(sequence):
    
    reberString = ''
    for i in xrange(len(sequence)):
        index = np.where(sequence[i]==1.)[0][0]
        reberString += chars[index]
    return reberString
52641
def _get_new_batch(self, ds_type:DatasetType)->Collection[Tensor]:
        ""
        return self.learn.data.one_batch(ds_type=ds_type, detach=True, denorm=False, cpu=False)
725817
def chop_sequence(sequence, limit_length):
        
        return [sequence[i:i + limit_length] for i in range(0, len(sequence), limit_length)]
248134
def _take_batch(self, min_records):
        ''''''

        if not self._buffer:
            return []

        enough_messages = len(self._buffer) >= min_records
        enough_time = time.time() - self.time_last_batch_sent >= self.batch_delay_seconds
        ready = enough_messages or enough_time

        if not ready:
            return []

        result = list(self._buffer)
        self._buffer.clear()
        return result
356528
def retrieve_outputs(self):
        

        metrics = {}
        for obs in self._observers['cv_metrics']:
            metrics[obs.name] = obs.retrieve_metrics()
        self.metrics = metrics
75500
def streams(self):
        

        if not self.get_objects_by_type('stream'):
            tpld_ids = []
            for index in self.get_attribute('ps_indices').split():
                stream = XenaStream(parent=self, index='{}/{}'.format(self.index, index))
                tpld_ids.append(stream.get_attribute('ps_tpldid'))
            if tpld_ids:
                XenaStream.next_tpld_id = max([XenaStream.next_tpld_id] + [int(t) for t in tpld_ids]) + 1
        return {s.id: s for s in self.get_objects_by_type('stream')}
104515
def target_sequence(self):
        # type: () -> SeqRecord
        
        if self.cutter.is_3overhang():
            start, end = self._match.span(2)[0], self._match.span(3)[1]
        else:
            start, end = self._match.span(1)[0], self._match.span(2)[1]
        return add_as_source(self.record, (self.record << start)[end - start :])
543865
def sequence(self):
        
        self.open()
        seq = lvm_vg_get_seqno(self.handle)
        self.close()
        return seq
150239
def sample_batch_trajectories(self, rollout_length):
        
        results = []

        for i in range(self.num_envs):
            results.append(self.sample_rollout_single_env(rollout_length))

        return np.stack(results, axis=-1)