paddle自定义组网提问
Created by: Masterkmp
你好,现在我需要在ernie搭建lstm,GNN等网络实现自定义组网的文本分类任务,现在假设我要实现自定义的ernie+listm网络。目前我参考了476和官方文档define_task_example,一直报错,请问如何解决呢,我也一直在调试,四天了还没有解决自定义组网的问题,该参考的都参考了,实际上参考的问题别人最后也没有最终解决,文档给出的define_task_example是描述的序列生成任务demo,而我需要做的是文本分类任务,当然方法是类似的,但是没有文本分类的自定义组网的参考。需要继承paddlehub\finetune\task\classifier_task.py中的ClassifierTask类实现新的文本分类任务,并且我也知道要通过继承ClassifierTask后覆盖def _build_net(self)等方法,甚至直接把class TextClassifierTask(ClassifierTask)里的代码直接拿来重写,但是依旧报错(不重写直接调用就没问题),这个问题已经耽误太长时间,真心希望paddlehub官方能帮着解决一下,而不是只给我一个实际没有解决的问题参考和不太完善的文档参考。 下面贴一下代码: 1、自定义组网部分 这段代码跑出来没问题,然后 这里开始报错了,如下: ` [2020-09-25 17:47:25,022] [ WARNING] - PaddleHub v1.8 has deprecated the reader and feed_list parameters in the nlp Task. We provided an easier usage, in which you can use your tokenizer to preprocess dataset and run task in a clear flow. New demo see https://github.com/PaddlePaddle/PaddleHub/blob/release/v1.8/demo/text_classification/text_cls.py [2020-09-25 17:47:25,495] [ INFO] - Strategy with warmup, linear decay, slanted triangle learning rate, weight decay regularization, /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py:1093: UserWarning: There are no operators in the program to be executed. If you pass Program manually, please use fluid.program_guard to ensure the current Program is being used. warnings.warn(error_info) [2020-09-25 17:47:25,509] [ INFO] - Try loading checkpoint from testdemo/ckpt.meta [2020-09-25 17:47:25,510] [ INFO] - PaddleHub model checkpoint not found, start from scratch... [2020-09-25 17:47:25,546] [ INFO] - PaddleHub finetune start
---------------------------------------------------------------------------TypeError Traceback (most recent call last) in 11 12 #开始Finetune ---> 13 run_states = cls_task.finetune_and_eval() /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py in finetune_and_eval(self) 943 944 def finetune_and_eval(self): --> 945 return self.finetune(do_eval=True) 946 947 def finetune(self, do_eval=False): /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py in finetune(self, do_eval) 964 while self.current_epoch <= self.config.num_epoch: 965 self.config.strategy.step() --> 966 run_states = self._run(do_eval=do_eval) 967 self.env.current_epoch += 1 968 /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py in _run(self, do_eval) 1174 if self.config.use_pyreader: 1175 data_loader = fluid.io.DataLoader.from_generator( -> 1176 feed_list=self.feed_var_list, 1177 capacity=64, 1178 use_double_buffer=True, /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/finetune/task/base_task.py in feed_var_list(self) 666 667 vars = self.main_program.global_block().vars --> 668 return [vars[varname] for varname in self.feed_list] 669 670 @property TypeError: 'method' object is not iterable `