Open zeeshansayyed opened 5 years ago
Is it possible to change MyNetwork to inherit from Block?
Unfortunately, no. What if I write custom NMTModelHybrid
class and copy the code from NMTModel
, add a hybrid_forward()
function and call forward()
inside hybrid_forward()
. This seems to be working, but I am not sure whether it is working correctly as the original NMTModel
is intended to be.
HybridBlock should only be used when the whole model can be hybridized, which means that it can be written via the symbolic APIs in MXNet. We should use Block if we cannot make such guarantee.
Get Outlook for iOShttps://aka.ms/o0ukef
From: Zeeshan Sayyed notifications@github.com Sent: Tuesday, October 15, 2019 2:00:15 AM To: dmlc/gluon-nlp gluon-nlp@noreply.github.com Cc: Xingjian SHI xshiab@connect.ust.hk; Comment comment@noreply.github.com Subject: Re: [dmlc/gluon-nlp] How to use nlp.model.translation.NMTModel inside a HybridBlock? (#973)
Unfortunately, no. What if I write custom NMTModelHybrid class and copy the code from NMTModel, add a hybrid_forward() function and call forward() inside hybrid_forward(). This seems to be working, but I am not sure whether it is working correctly as the original NMTModel is intended to be.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/dmlc/gluon-nlp/issues/973?email_source=notifications&email_token=ABHQH3VD2E5YQB6WRAYFMGLQOWBB7A5CNFSM4JAQ5GNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBH7ZRY#issuecomment-542112967, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABHQH3TD2OIIEFL2KNXS52TQOWBB7ANCNFSM4JAQ5GNA.
I want to use NMTModel inside a network which is HybridBlock. Something like this:
I run into the following error:
ValueError: Children of HybridBlock must also be HybridBlock, but NMTModel() has type <class 'gluonnlp.model.translation.NMTModel'>. If you are using Sequential, please try HybridSequential instead.
What would be the easiest way of solving this problem? Should I implement my own version of NMTModel which inherits HybridBlock instead of Block?