Exemplo n.º 1
0
 def sample_many(self, input, batch_rep=1, iter_rep=1):
     return sample_many(
         lambda input: self._inner(*input
                                   ),  # Need to unpack tuple into arguments
         lambda input, pi: self.problem.get_costs(input[
             0], pi),  # Don't need embeddings as input to get_costs
         (input, self.embeder(self.init_embed(input))
          ),  # Pack input with embeddings (additional input)
         batch_rep,
         iter_rep)
 def sample_many(self, input, batch_rep=1, iter_rep=1):
     """
     :param input: (batch_size, graph_size, node_dim) input node features
     :return:
     """
     # Bit ugly but we need to pass the embeddings as well.
     # Making a tuple will not work with the problem.get_cost function
     return sample_many(
         lambda input: self._inner(*input),  # Need to unpack tuple into arguments
         lambda input, pi: self.problem.get_costs(input[0], pi),  # Don't need embeddings as input to get_costs
         (input, self.embedder(self._init_embed(input))[0]),  # Pack input with embeddings (additional input)
         batch_rep, iter_rep
     )
Exemplo n.º 3
0
 def sample_many(self, input, graph, batch_rep=1, iter_rep=1):
     # Bit ugly but we need to pass the embeddings as well.
     # Making a tuple will not work with the problem.get_cost function
     # Params: inner_func, get_cost_func, input, batch_rep, iter_rep
     return sample_many(
         # Need to unpack tuple into arguments
         lambda input: self._inner(*input),
         # Don't need embeddings as input to get_costs
         lambda input, pi: self.problem.get_costs(input[0], pi),  
         # Pack input with embeddings (additional input)
         (input, graph, self.embedder(self._init_embed(input), graph)),
         batch_rep, iter_rep
     )