diff --git a/hub_module/modules/text/semantic_model/bert_cased_L_12_H_768_A_12/README.md b/hub_module/modules/text/semantic_model/bert_cased_L_12_H_768_A_12/README.md index 8466b8e43cee52670ca79829e260deee8559662e..002f621e8dd650bb0a8b7c80a2209e180dda84af 100644 --- a/hub_module/modules/text/semantic_model/bert_cased_L_12_H_768_A_12/README.md +++ b/hub_module/modules/text/semantic_model/bert_cased_L_12_H_768_A_12/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` diff --git a/hub_module/modules/text/semantic_model/bert_cased_L_24_H_1024_A_16/README.md b/hub_module/modules/text/semantic_model/bert_cased_L_24_H_1024_A_16/README.md index 3b09123d10683761f1269a701fb97849c2981b2d..1e3421417439c17df69ab76bfd437c577fd320af 100644 --- a/hub_module/modules/text/semantic_model/bert_cased_L_24_H_1024_A_16/README.md +++ b/hub_module/modules/text/semantic_model/bert_cased_L_24_H_1024_A_16/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/bert_chinese_L_12_H_768_A_12/README.md b/hub_module/modules/text/semantic_model/bert_chinese_L_12_H_768_A_12/README.md index 320511c44dc5deda8ee98e4b22ddb4f1b0523ed9..9604701172489ea9853460fde5c08dd9198eb4eb 100644 --- a/hub_module/modules/text/semantic_model/bert_chinese_L_12_H_768_A_12/README.md +++ b/hub_module/modules/text/semantic_model/bert_chinese_L_12_H_768_A_12/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/bert_multi_cased_L_12_H_768_A_12/README.md b/hub_module/modules/text/semantic_model/bert_multi_cased_L_12_H_768_A_12/README.md index 9a1914088faa50ab27d5505a1964e94d3fe5b3bd..48621361df149195a52c4d3069626afe000e650e 100644 --- a/hub_module/modules/text/semantic_model/bert_multi_cased_L_12_H_768_A_12/README.md +++ b/hub_module/modules/text/semantic_model/bert_multi_cased_L_12_H_768_A_12/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/bert_multi_uncased_L_12_H_768_A_12/README.md b/hub_module/modules/text/semantic_model/bert_multi_uncased_L_12_H_768_A_12/README.md index a19701ed17694188ffc3e739fbeb3c2acb7ca9d0..754f1ee0a26aed6d12e5ffebf968007ce5be273c 100644 --- a/hub_module/modules/text/semantic_model/bert_multi_uncased_L_12_H_768_A_12/README.md +++ b/hub_module/modules/text/semantic_model/bert_multi_uncased_L_12_H_768_A_12/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/bert_uncased_L_12_H_768_A_12/README.md b/hub_module/modules/text/semantic_model/bert_uncased_L_12_H_768_A_12/README.md index a62212d4e09aceca78f5471f24a3d27dfbb8c9a5..b157a8bb40b1c4a7a604dd0f052be8dfcdf576dc 100644 --- a/hub_module/modules/text/semantic_model/bert_uncased_L_12_H_768_A_12/README.md +++ b/hub_module/modules/text/semantic_model/bert_uncased_L_12_H_768_A_12/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/bert_uncased_L_24_H_1024_A_16/README.md b/hub_module/modules/text/semantic_model/bert_uncased_L_24_H_1024_A_16/README.md index 73893de6d3a7668a14b2b91f47d1eb4f5769e388..bf84872d2fae8b3f06627913d41b57f5627838f3 100644 --- a/hub_module/modules/text/semantic_model/bert_uncased_L_24_H_1024_A_16/README.md +++ b/hub_module/modules/text/semantic_model/bert_uncased_L_24_H_1024_A_16/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/chinese_bert_wwm/README.md b/hub_module/modules/text/semantic_model/chinese_bert_wwm/README.md index 34900f514c012dc58f3fcd782b973406a615ff05..96ae17ac8cd73754c04000c8f2f847b2c2556402 100644 --- a/hub_module/modules/text/semantic_model/chinese_bert_wwm/README.md +++ b/hub_module/modules/text/semantic_model/chinese_bert_wwm/README.md @@ -114,7 +114,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 @@ -218,7 +218,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/chinese_bert_wwm_ext/README.md b/hub_module/modules/text/semantic_model/chinese_bert_wwm_ext/README.md index 99c6319f658ba5325f11fe7225e905b2322af102..79d742a5d9cd842cacd26024ca04995c4b81009b 100644 --- a/hub_module/modules/text/semantic_model/chinese_bert_wwm_ext/README.md +++ b/hub_module/modules/text/semantic_model/chinese_bert_wwm_ext/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/chinese_electra_base/README.md b/hub_module/modules/text/semantic_model/chinese_electra_base/README.md index 0d4345652c16e101d5e53433b4a38a454a12f038..9fbf6b605e656c101e8e2bd96e4c910f697384f4 100644 --- a/hub_module/modules/text/semantic_model/chinese_electra_base/README.md +++ b/hub_module/modules/text/semantic_model/chinese_electra_base/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` diff --git a/hub_module/modules/text/semantic_model/chinese_electra_small/README.md b/hub_module/modules/text/semantic_model/chinese_electra_small/README.md index d704b823716370cb68d87041395b11c2b93d5311..34580f1d635a49df7c4d5e978cfb1ac2e4bd8ebd 100644 --- a/hub_module/modules/text/semantic_model/chinese_electra_small/README.md +++ b/hub_module/modules/text/semantic_model/chinese_electra_small/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` diff --git a/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext/README.md b/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext/README.md index e0c4027daecf9f7a127059ff99a725f77011f748..fcd9cd5c3030d210573916ce5da112c698e580ad 100644 --- a/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext/README.md +++ b/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext_large/README.md b/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext_large/README.md index 16fc2068a44c46562d350e2efec1480381b3f19b..517ced4bd655b5e756788d77f42222c8628391f3 100644 --- a/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext_large/README.md +++ b/hub_module/modules/text/semantic_model/chinese_roberta_wwm_ext_large/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/ernie/README.md b/hub_module/modules/text/semantic_model/ernie/README.md index a5c662dc866c040750a337f1dd6381e9e9473f59..ce5e557368a1b192033add891f928189901c0140 100644 --- a/hub_module/modules/text/semantic_model/ernie/README.md +++ b/hub_module/modules/text/semantic_model/ernie/README.md @@ -107,7 +107,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` 利用该PaddleHub Module Fine-tune示例,可参考[文本分类](https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.2/demo/text-classification)、[序列标注](https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.2/demo/sequence-labeling)。 diff --git a/hub_module/modules/text/semantic_model/ernie_tiny/README.md b/hub_module/modules/text/semantic_model/ernie_tiny/README.md index b4ecaae282e74338f64c0ab0706fb1697aa5552c..19805393c915cbb1a4123f8741fc4876b7a4a68b 100644 --- a/hub_module/modules/text/semantic_model/ernie_tiny/README.md +++ b/hub_module/modules/text/semantic_model/ernie_tiny/README.md @@ -94,7 +94,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` 利用该PaddleHub Module Fine-tune示例,可参考[文本分类](https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.4.0/demo/text-classification)。 diff --git a/hub_module/modules/text/semantic_model/ernie_v2_eng_base/README.md b/hub_module/modules/text/semantic_model/ernie_v2_eng_base/README.md index f625dfced1059366983b9a94d5e9f14323743795..784b63d1b392c5cae948020b45789d8f03118d6b 100644 --- a/hub_module/modules/text/semantic_model/ernie_v2_eng_base/README.md +++ b/hub_module/modules/text/semantic_model/ernie_v2_eng_base/README.md @@ -100,7 +100,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` 利用该PaddleHub Module Fine-tune示例,可参考[文本分类](https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.4.0/demo/text-classification)。 diff --git a/hub_module/modules/text/semantic_model/ernie_v2_eng_large/README.md b/hub_module/modules/text/semantic_model/ernie_v2_eng_large/README.md index 47386cc2ccfcbec0b5dccd926be74e7c6b2e73db..e10d7d26eb2b32bc09f5efd5e1442d3a7014e058 100644 --- a/hub_module/modules/text/semantic_model/ernie_v2_eng_large/README.md +++ b/hub_module/modules/text/semantic_model/ernie_v2_eng_large/README.md @@ -103,7 +103,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` 利用该PaddleHub Module Fine-tune示例,可参考[文本分类](https://github.com/PaddlePaddle/PaddleHub/tree/release/v1.2/demo/text-classification)。 diff --git a/hub_module/modules/text/semantic_model/rbt3/README.md b/hub_module/modules/text/semantic_model/rbt3/README.md index 522ac1a309e5e0d8b654b37889694a9cd9003dc2..a9a001d882329fa4d28ac44a0f21627753bb320b 100644 --- a/hub_module/modules/text/semantic_model/rbt3/README.md +++ b/hub_module/modules/text/semantic_model/rbt3/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/hub_module/modules/text/semantic_model/rbtl3/README.md b/hub_module/modules/text/semantic_model/rbtl3/README.md index a61a7ca948702e0611745d1bc7894809fc06826b..531072714c66b53a9b3b2d854c6a78ab52ed85a4 100644 --- a/hub_module/modules/text/semantic_model/rbtl3/README.md +++ b/hub_module/modules/text/semantic_model/rbtl3/README.md @@ -96,7 +96,7 @@ embedding_result = module.get_embedding(texts=[["Sample1_text_a"],["Sample2_text # Use "get_params_layer" to get params layer and used to ULMFiTStrategy. params_layer = module.get_params_layer() -strategy = hub.finetune.strategy.ULMFiTStrategy(params_layer=params_layer) +strategy = hub.finetune.strategy.ULMFiTStrategy(frz_params_layer=params_layer, dis_params_layer=params_layer) ``` ## 查看代码 diff --git a/paddlehub/finetune/strategy.py b/paddlehub/finetune/strategy.py index 9073f9414e4b44078c59dfa5cb251cc031456a9f..2b90c5fa79033c798d4450fb9e8bfdb9c831119f 100644 --- a/paddlehub/finetune/strategy.py +++ b/paddlehub/finetune/strategy.py @@ -511,10 +511,6 @@ class CombinedStrategy(DefaultStrategy): unfreeze_depths=self. sorted_depth[:self.max_depth * self.epoch // self.scheduler["gradual_unfreeze"]["blocks"]]) - else: - logger.warning( - "The max op-depth in the network is %s. That results in that can't use the gradual unfreeze finetune strategy." - % (self.max_depth)) elif self.scheduler["gradual_unfreeze"]["params_layer"]: max_layer = max( self.scheduler["gradual_unfreeze"]["params_layer"].values()) @@ -631,8 +627,9 @@ class ULMFiTStrategy(CombinedStrategy): ratio=32, dis_blocks=3, factor=2.6, + dis_params_layer=None, frz_blocks=3, - params_layer=None): + frz_params_layer=None): scheduler = { "slanted_triangle": { @@ -641,12 +638,12 @@ class ULMFiTStrategy(CombinedStrategy): }, "gradual_unfreeze": { "blocks": frz_blocks, - "params_layer": params_layer + "params_layer": frz_params_layer }, "discriminative": { "blocks": dis_blocks, "factor": factor, - "params_layer": params_layer + "params_layer": dis_params_layer } } regularization = {} diff --git a/paddlehub/finetune/task/base_task.py b/paddlehub/finetune/task/base_task.py index cd2ffd9e9edd880e328bef63840239b43ed31ed0..10d2de74c262d9d5221c389f0afffe49de74c9ad 100644 --- a/paddlehub/finetune/task/base_task.py +++ b/paddlehub/finetune/task/base_task.py @@ -36,7 +36,7 @@ from visualdl import LogWriter import paddlehub as hub from paddlehub.common.paddle_helper import dtype_map, clone_program -from paddlehub.common.utils import mkdir, version_compare +from paddlehub.common.utils import mkdir from paddlehub.common.dir import tmp_dir from paddlehub.common.logger import logger from paddlehub.finetune.checkpoint import load_checkpoint, save_checkpoint @@ -951,12 +951,6 @@ class BaseTask(object): Returns: RunState: the running result of predict phase """ - - if isinstance(self._base_data_reader, hub.reader.LACClassifyReader): - raise Exception( - "LACClassifyReader does not support predictor, please close accelerate_mode" - ) - global_run_states = [] period_run_states = [] @@ -998,6 +992,12 @@ class BaseTask(object): Returns: RunState: the running result of predict phase """ + if accelerate_mode and isinstance(self._base_data_reader, + hub.reader.LACClassifyReader): + logger.warning( + "LACClassifyReader does not support predictor, the accelerate_mode is closed now." + ) + accelerate_mode = False self.accelerate_mode = accelerate_mode with self.phase_guard(phase="predict"): diff --git a/paddlehub/finetune/task/reading_comprehension_task.py b/paddlehub/finetune/task/reading_comprehension_task.py index f0d6ab61e158e33b1319f614030cd099af3d6187..cb01f0eb7075915d78f8835b08c70ff82cef5959 100644 --- a/paddlehub/finetune/task/reading_comprehension_task.py +++ b/paddlehub/finetune/task/reading_comprehension_task.py @@ -205,7 +205,7 @@ def get_predictions(all_examples, all_features, all_results, n_best_size, for (feature_index, feature) in enumerate(features): if feature.unique_id not in unique_id_to_result: logger.info( - "As using pyreader, the last one batch is so small that the feature %s in the last batch is discarded " + "As using multidevice, the last one batch is so small that the feature %s in the last batch is discarded " % feature.unique_id) continue result = unique_id_to_result[feature.unique_id] diff --git a/paddlehub/module/nlp_module.py b/paddlehub/module/nlp_module.py index 0ebcf23636de3e548560710806d90df580118abb..f472619b8399a4bad6fd583fb12387bfb8ab2b67 100644 --- a/paddlehub/module/nlp_module.py +++ b/paddlehub/module/nlp_module.py @@ -397,7 +397,8 @@ class TransformerModule(NLPBaseModule): return inputs, outputs, module_program - def get_embedding(self, texts, use_gpu=False, batch_size=1): + def get_embedding(self, texts, max_seq_len=512, use_gpu=False, + batch_size=1): """ get pooled_output and sequence_output for input texts. Warnings: this method depends on Paddle Inference Library, it may not work properly in PaddlePaddle <= 1.6.2. @@ -405,6 +406,7 @@ class TransformerModule(NLPBaseModule): Args: texts (list): each element is a text sample, each sample include text_a and text_b where text_b can be omitted. for example: [[sample0_text_a, sample0_text_b], [sample1_text_a, sample1_text_b], ...] + max_seq_len (int): the max sequence length. use_gpu (bool): use gpu or not, default False. batch_size (int): the data batch size, default 1. @@ -417,12 +419,12 @@ class TransformerModule(NLPBaseModule): ) or self.emb_job["batch_size"] != batch_size or self.emb_job[ "use_gpu"] != use_gpu: inputs, outputs, program = self.context( - trainable=True, max_seq_len=self.MAX_SEQ_LEN) + trainable=True, max_seq_len=max_seq_len) reader = hub.reader.ClassifyReader( dataset=None, vocab_path=self.get_vocab_path(), - max_seq_len=self.MAX_SEQ_LEN, + max_seq_len=max_seq_len, sp_model_path=self.get_spm_path() if hasattr( self, "get_spm_path") else None, word_dict_path=self.get_word_dict_path() if hasattr( diff --git a/paddlehub/reader/nlp_reader.py b/paddlehub/reader/nlp_reader.py index dc7549983b01b16496178801ebb49fb7ce84033b..7cf4cf67ce70de850ca0c04dc4cc37d58ee8c6f2 100644 --- a/paddlehub/reader/nlp_reader.py +++ b/paddlehub/reader/nlp_reader.py @@ -1113,7 +1113,7 @@ class LACClassifyReader(BaseReader): return processed - if not self.has_processed[phase]: + if not self.has_processed[phase] or phase == "predict": logger.info( "processing %s data now... this may take a few minutes" % phase) for i in range(len(data)):