parameters: (self, out, rows)
docstring: Produce a batch of data samples.
  
          Batch data is output to `out` and valid matrix rows are output
          to `rows`. `out` should be a `np.ndarray` with type
          `np.float64` and dimensions `batch_size` x `sample_size`.
          `rows` should be a `list`.
  
          Walk data is read from the walk file in a background thread.
docstring_summary: Produce a batch of data samples.
docstring_tokens: Produce a batch of data samples .
function: def _generate_batch(self, out, rows):
          """Produce a batch of data samples.
  
          Batch data is output to `out` and valid matrix rows are output
          to `rows`. `out` should be a `np.ndarray` with type
          `np.float64` and dimensions `batch_size` x `sample_size`.
          `rows` should be a `list`.
  
          Walk data is read from the walk file in a background thread.
  
          """
          initialize_rng()
  
          # Get walks and start reading next batch in background
          if self.next_walk_batch_thread is None:
              self._read_walks()
          else:
              self.next_walk_batch_thread.join()
          walks = self.next_walk_batch
          batch_size = min(walks.shape[0], out.shape[0])
          self.next_walk_batch_thread = threading.Thread(target=self._read_walks)
          self.next_walk_batch_thread.start()
  
          # Update negative sampling distribution, if needed
          self._record_walk_visits(walks)
          if self.total_visit_count > 2*self.noise_visit_count:
              self._update_noise_distribution()
  
          # Generate negative samples
          rands = np.random.uniform(size=(batch_size, self.num_negative_samples))
          negative_samples = np.searchsorted(self.noise_cdf, rands)
  
          # Populate output matrix with data samples
          col0 = 0
          col1 = self.num_negative_samples
          col2 = self.num_negative_samples + self.walk_length
          out[:batch_size,col0:col1] = negative_samples
          out[:batch_size,col1:col2] = walks[:batch_size]
  
          # Construct list of valid rows in output matrix
          rows.clear()
          rows.extend(range(batch_size))
          np.random.shuffle(rows)
function_tokens: def _generate_batch ( self , out , rows ) : initialize_rng ( ) # Get walks and start reading next batch in background if self . next_walk_batch_thread is None : self . _read_walks ( ) else : self . next_walk_batch_thread . join ( ) walks = self . next_walk_batch batch_size = min ( walks . shape [ 0 ] , out . shape [ 0 ] ) self . next_walk_batch_thread = threading . Thread ( target = self . _read_walks ) self . next_walk_batch_thread . start ( ) # Update negative sampling distribution, if needed self . _record_walk_visits ( walks ) if self . total_visit_count > 2 * self . noise_visit_count : self . _update_noise_distribution ( ) # Generate negative samples rands = np . random . uniform ( size = ( batch_size , self . num_negative_samples ) ) negative_samples = np . searchsorted ( self . noise_cdf , rands ) # Populate output matrix with data samples col0 = 0 col1 = self . num_negative_samples col2 = self . num_negative_samples + self . walk_length out [ : batch_size , col0 : col1 ] = negative_samples out [ : batch_size , col1 : col2 ] = walks [ : batch_size ] # Construct list of valid rows in output matrix rows . clear ( ) rows . extend ( range ( batch_size ) ) np . random . shuffle ( rows )