def from_config(config): if not config: return None config_dict = config.to_dict() config_dict = remove_empty_keys(config_dict) return SubGraph.objects.create(definition=json.dumps(config_dict))
def from_config(config): if not config: return None config_dict = config.to_dict() config_dict = remove_empty_keys(config_dict) return AgentMemory.objects.create(**config_dict)
def from_config(config): if not config: return None config_dict = config.to_dict() config_dict.pop('memory_config', None) config_dict['memory'] = AgentMemory.from_config(config.memory_config) config_dict = remove_empty_keys(config_dict) return Agent.objects.create(**config_dict)
def from_config(config): if not config: return None config_dict = config.to_dict() config_dict['definition'] = json.dumps( config_dict.get('definition', {})) config_dict = remove_empty_keys(config_dict) pipeline = Pipeline.objects.create(**config_dict) return pipeline
def from_config(config): config_dict = BaseExperiment.from_config(config) config_dict['agent'] = Agent.from_config(config.agent_config) config_dict.pop('agent_config', None) config_dict['environment'] = Environment.from_config( config.environment_config) config_dict.pop('environment_config', None) eval_metrics = config_dict.pop('eval_metrics') config_dict = remove_empty_keys(config_dict) exp = RLExperiment.objects.create(**config_dict) exp.eval_metrics = eval_metrics return exp
def from_config(config): config_dict = BaseExperiment.from_config(config) config_dict['estimator'] = Estimator.from_config( config.estimator_config) config_dict.pop('estimator_config', None) config_dict['train_input_data'] = InputData.from_config( config.train_input_data_config) config_dict.pop('train_input_data_config', None) config_dict['eval_input_data'] = InputData.from_config( config.eval_input_data_config) config_dict.pop('eval_input_data_config', None) eval_metrics = config_dict.pop('eval_metrics') config_dict = remove_empty_keys(config_dict) exp = Experiment.objects.create(**config_dict) exp.eval_metrics = eval_metrics return exp
def from_config(config): if not config: return None params = {} fields = [f.name for f in PolyaxonModel._meta.get_fields()] config_dict = config.to_dict() if not isinstance(config_dict.get('summaries', []), list): config_dict['summaries'] = [config_dict['summaries']] config_dict['params'] = params config_dict['loss'] = Loss.from_config(config.loss_config) config_dict.pop('loss_config', None) config_dict['optimizer'] = Optimizer.from_config( config.optimizer_config) config_dict.pop('optimizer_config', None) config_dict['graph'] = SubGraph.from_config(config.graph_config) config_dict.pop('graph_config', None) config_dict['encoder'] = Encoder.from_config(config.encoder_config) config_dict.pop('encoder_config', None) config_dict['decoder'] = Decoder.from_config(config.decoder_config) config_dict.pop('decoder_config', None) config_dict['bridge'] = Bridge.from_config(config.bridge_config) config_dict.pop('bridge_config', None) # also remove eval_metrics_config config_dict.pop('eval_metrics_config', None) # Rest of the keys should go to params keys = list(config_dict.keys()) for key in keys: if key not in fields: params[key] = config_dict.pop(key) config_dict['params'] = params config_dict = remove_empty_keys(config_dict) model = PolyaxonModel.objects.create(**config_dict) model.eval_metrics = [ Metric.from_config(m) for m in config.eval_metrics_config ] return model