如何在动态图模式下让子类调用父类的方法
Created by: liu0haha123
飞桨版本1.7.2 python3.6 使用ERINE做ErnieModelForTokenClassification 时需要获取中间的变量 的 pool,encoded pooled, encoded = super(ErnieModelForTokenClassification, self).forward(*args, **kwargs)
我使用 sequence_output,encoded = self.erine_for_token.ErnieModel.forward(src_ids=batch_data,sents_id = None,input_mask=batch_masks)
报错信息:
Traceback (most recent call last):
File "D:\Anaconda\envs\paddle\lib\site-packages\fire\core.py", line 468, in _Fire
target=component.__name__)
File "D:\Anaconda\envs\paddle\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "E:/Paddlesanyuanzuchouqu/main.py", line 119, in train
tags = F.dygraph.to_variable(tags).astype("float32")
File "D:\Anaconda\envs\paddle\lib\site-packages\paddle\fluid\dygraph\layers.py", line 461, in __call__
outputs = self.forward(*inputs, **kwargs)
File "E:\Paddlesanyuanzuchouqu\models\ERINE_MUL_CNN.py", line 123, in forward
sequence_output,encoded = self.erine_for_token.ErnieModel.forward(src_ids=batch_data,sents_id = None,input_mask=batch_masks)
File "D:\Anaconda\envs\paddle\lib\site-packages\paddle\fluid\dygraph\layers.py", line 533, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'ErnieModelForTokenClassification' object has no attribute 'ErnieModel'
如何调用ErnieModel的forward方法