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) }
def _parse_individual(json, create_genome): return Individual.decode(create_genome, json['parameters'], is_local=False, learning_rate=json['learning_rate'], optimizer_state=StateEncoder.decode( json['optimizer_state']), source=json['source'], id=json['id'])
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
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
def encoded_parameters(self, value): """ :param value: base64 encoded representation of the networks state dictionary """ self.net.load_state_dict(StateEncoder.decode(value))
def encoded_parameters(self): """ :return: base64 encoded representation of the networks state dictionary """ return StateEncoder.encode(self.net.state_dict())