コード例 #1
0
 def _individual_to_json(individual):
     return {
         'id': individual.id,
         'parameters': individual.genome.encoded_parameters,
         'learning_rate': individual.learning_rate,
         'optimizer_state': StateEncoder.encode(individual.optimizer_state)
     }
コード例 #2
0
    def _individual_to_json(individual):
        json_response = {
            'id': individual.id,
            'parameters': individual.genome.encoded_parameters,
            'learning_rate': individual.learning_rate,
            'optimizer_state': StateEncoder.encode(individual.optimizer_state)
        }
        if individual.iteration is not None:
            json_response['iteration'] = individual.iteration

        return json_response
コード例 #3
0
def individual_to_dict(individual):
    individual_dict = {
        'id': individual.id,
        'parameters': individual.genome.encoded_parameters,
        'learning_rate': individual.learning_rate,
        'optimizer_state': StateEncoder.encode(individual.optimizer_state)
    }
    if individual.iteration is not None:
        individual_dict['iteration'] = individual.iteration

    return individual_dict
コード例 #4
0
 def encoded_parameters(self):
     """
     :return: base64 encoded representation of the networks state dictionary
     """
     return StateEncoder.encode(self.net.state_dict())