Esempio n. 1
0
 def chunk(self, targets):
     sizes = chunk_sizes(self.lengths, len(targets))
     chunks = chunk_tensor(self.tensor, sizes, targets, dim=0)
     result = []
     step = len(self.lengths) // len(targets)
     for idx, chunk in enumerate(chunks):
         the_tensor = PackedTensor(chunk, split=self.split, box=self.box)
         the_tensor.lengths = self.lengths[idx * step:(idx + 1) * step]
         the_tensor = the_tensor if self.box else the_tensor.tensor
         result.append(the_tensor)
     return result
Esempio n. 2
0
 def chunk(self, targets):
     sizes = chunk_sizes(self.lengths, len(targets))
     result = []
     offset = 0
     for size in sizes:
         the_copy = copy(self)
         the_copy.connections = [[
             item - offset for item in connection
         ] for connection in self.connections[offset:offset + size]]
         result.append(the_copy)
         offset += size
     return result
Esempio n. 3
0
 def chunk(self, targets):
   sizes = chunk_sizes(self.counts, len(targets))
   result = []
   offset = 0
   for idx, size in enumerate(sizes):
     the_copy = copy(self)
     the_copy.indices = self.indices[offset:offset + size]
     the_copy.indices = the_copy.indices - the_copy.indices[0]
     the_copy.indices = the_copy.indices.to(targets[idx])
     the_copy.unique, the_copy.counts = the_copy.indices.unique(return_counts=True)
     result.append(the_copy)
     offset += the_copy.indices.size(0)
   return result
Esempio n. 4
0
 def chunk(self, targets):
   connections = []
   sizes = chunk_sizes(self.lengths, len(targets))
   step = len(self.lengths) // len(targets)
   offset = 0
   for idx, size in enumerate(sizes):
     the_connections = self.connections[offset:offset + size] - offset
     the_connections = the_connections.to(targets[idx])
     result = ConstantStructure(self.source, self.target, the_connections)
     result.lengths = self.lengths[step * idx:step * (idx + 1)]
     connections.append(result)
     offset += size
   return connections
Esempio n. 5
0
 def chunk(self, targets):
   sizes = chunk_sizes(self.lengths, len(targets))
   step = len(self.lengths) // len(targets)
   result = []
   offset = 0
   index_offset = 0
   for idx, size in enumerate(sizes):
     the_copy = copy(self)
     the_copy.indices = self.indices[offset:offset + size] - index_offset
     the_copy.connections = self.connections[offset:offset + size] - index_offset
     the_copy.lengths = self.lengths[idx * step:(idx + 1) * step]
     the_copy.node_counts = self.node_counts[idx * step:(idx + 1) * step]
     the_copy.node_count = sum(the_copy.node_counts)
     result.append(the_copy)
     offset += size
     index_offset += the_copy.node_count
   return result