Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
train_config.gram_dict_input = MODELS_PATHS[language]["gram_input"]
if train_config.gram_dict_output is None:
train_config.gram_dict_output = MODELS_PATHS[language]["gram_output"]
if train_config.word_vocabulary is None:
train_config.word_vocabulary = MODELS_PATHS[language]["word_vocabulary"]
if train_config.char_set_path is None:
train_config.char_set_path = MODELS_PATHS[language]["char_set"]
build_config = BuildModelConfig()
build_config.load(build_config_path)
if build_config.char_model_weights_path is None:
build_config.char_model_weights_path = MODELS_PATHS[language]["char_model_weights"]
if build_config.char_model_config_path is None:
build_config.char_model_config_path = MODELS_PATHS[language]["char_model_config"]
model = LSTMMorphoAnalysis(language)
model.prepare(train_config.gram_dict_input, train_config.gram_dict_output,
train_config.word_vocabulary, train_config.char_set_path, file_names)
if os.path.exists(train_config.eval_model_config_path) and not train_config.rewrite_model:
model.load_train(build_config, train_config.train_model_config_path, train_config.train_model_weights_path)
print(model.eval_model.summary())
else:
embeddings = None
if embeddings_path is not None:
embeddings = load_embeddings(embeddings_path, model.word_vocabulary, build_config.word_max_count)
print(embeddings.shape)
model.build(build_config, embeddings)
model.train(file_names, train_config, build_config)