def CreateModel(self, config=None, topics_count=None, inner_iterations_count=None, topic_names=None, class_ids=None, class_weights=None): if config is None: config = messages_pb2.ModelConfig() if topics_count is not None: config.topics_count = topics_count if inner_iterations_count is not None: config.inner_iterations_count = inner_iterations_count if topic_names is not None: config.ClearField('topic_name') for topic_name in topic_names: config.topic_name.append(topic_name) if class_ids is not None: config.ClearField('class_id') for class_id in class_ids: config.class_id.append(class_id) if class_weights is not None: config.ClearField('class_weight') for class_weight in class_weights: config.class_weight.append(class_weight) return Model(self, config)
def EnableRegularizer(self, regularizer, tau): config_copy_ = messages_pb2.ModelConfig() config_copy_.CopyFrom(self.config_) config_copy_.regularizer_name.append(regularizer.name()) config_copy_.regularizer_tau.append(tau) self.Reconfigure(config_copy_)
def EnableScore(self, score): # obsolete in BigARTM v0.6.3 config_copy_ = messages_pb2.ModelConfig() config_copy_.CopyFrom(self.config_) config_copy_.score_name.append(score.name()) self.Reconfigure(config_copy_)
def Disable(self): config_copy_ = messages_pb2.ModelConfig() config_copy_.CopyFrom(self.config_) config_copy_.enabled = False self.Reconfigure(config_copy_)
stream = messages_pb2.Stream() stream.name = ('stream_8') stream.type = Stream_Type_Global stream.modulus = 3 stream.residuals.append(1) # Create regularizer_config dirichlet_theta_config = messages_pb2.DirichletThetaConfig() alpha = dirichlet_theta_config.alpha.add() alpha.value.append(0.1) dirichlet_phi_config = messages_pb2.DirichletPhiConfig() dirichlet_phi_config.dictionary_name = 'dictionary_1' # Create model_config model_config = messages_pb2.ModelConfig() model_config.stream_name = ('stream_0') model_config.regularizer_name.append('regularizer_1') model_config.regularizer_tau.append(1) model_config.regularizer_name.append('regularizer_2') model_config.regularizer_tau.append(2) model_config.score_name.append('perplexity_score') model_config_new = messages_pb2.ModelConfig() model_config_new.CopyFrom(model_config) model_config_new.inner_iterations_count = 20 dictionary_config = messages_pb2.DictionaryConfig() dictionary_config.name = 'dictionary_1' entry_1 = dictionary_config.entry.add()