-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
将pytorch模型转换为fastNLP可用的模型 #286
Comments
首先确认对应的DataSet中有input, hidden这两个field,且被设置为了input。可以通过dataset.rename_field()将dataset中的field改为这两个名字。另外就是把forward中的返回值改成字典,比如下面所示 def forward(self,input ,hidden):
combined=torch.cat((input,hidden),1)
hidden=self.i2h(combined)
output=self.i2o(combined)
output=self.softmax(output)
return {'pred':output, 'hidden':hidden} |
5 tasks
This was referenced Dec 4, 2020
5 tasks
This was referenced Sep 22, 2021
Closed
5 tasks
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
你好,我在尝试使用fastNLP构建自己的模型的时候遇到了问题。
pytorch教程[https://pytorch.apachecn.org/]中有一个字符级的文本生成模型
我想用fastNLP重写一次,但是在写的时候遇到一个问题,fastNLP要求返回数据为一个字典类型{'pred':outputs},那对于这个模型应该如何改写呢?
谢谢~
The text was updated successfully, but these errors were encountered: