samhodge opened a new issue #9813: Unable to save gluon model to symbolic 
network : neural style
URL: https://github.com/apache/incubator-mxnet/issues/9813
 
 
   ## Description
   see: https://github.com/zhanghang1989/MXNet-Gluon-Style-Transfer/issues/2
    within 
https://github.com/apache/incubator-mxnet/tree/master/example/gluon/style_transfer
   There are a number of Hybrid* with only forward and not hybrid forward 
defined, so the model cannot be serialised to a Symbol network, as a described 
in:
   
   https://mxnet.incubator.apache.org/tutorials/gluon/hybrid.html
   
   ## Environment info (Required)
   ----------Python Info----------
   ('Version      :', '2.7.14')
   ('Compiler     :', 'GCC 4.2.1 Compatible Clang 4.0.1 
(tags/RELEASE_401/final)')
   ('Build        :', ('default', 'Dec  7 2017 11:07:58'))
   ('Arch         :', ('64bit', ''))
   ------------Pip Info-----------
   ('Version      :', '9.0.1')
   ('Directory    :', '/Users/sam/anaconda2/lib/python2.7/site-packages/pip')
   ----------MXNet Info-----------
   
/Users/sam/anaconda2/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py:46:
 DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom 
instead
     import OpenSSL.SSL
   ('Version      :', '1.0.0')
   ('Directory    :', '/Users/sam/anaconda2/lib/python2.7/site-packages/mxnet')
   ('Commit Hash   :', '9ef196909ec7bf9cdda66d5b97c92793109798e1')
   ----------System Info----------
   ('Platform     :', 'Darwin-16.7.0-x86_64-i386-64bit')
   ('system       :', 'Darwin')
   ('node         :', 'kaos.fritz.box')
   ('release      :', '16.7.0')
   ('version      :', 'Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 
2017; root:xnu-3789.70.16~2/RELEASE_X86_64')
   ----------Hardware Info----------
   ('machine      :', 'x86_64')
   ('processor    :', 'i386')
   machdep.cpu.extfeatures: SYSCALL XD 1GBPAGE EM64T LAHF LZCNT PREFETCHW 
RDTSCP TSCI
   machdep.cpu.leaf7_features: SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 HLE 
AVX2 BMI2 INVPCID RTM SMAP RDSEED ADX IPT SGX FPU_CSDS MPX CLFSOPT
   machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE 
MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ 
DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC 
MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C
   machdep.cpu.brand_string: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
   ----------Network Test----------
   Setting timeout: 10
   Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.2019 
sec, LOAD: 1.9668 sec.
   Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0498 sec, LOAD: 
0.4649 sec.
   Timing for FashionMNIST: 
https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz,
 DNS: 0.0760 sec, LOAD: 2.2928 sec.
   Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 1.2123 sec, 
LOAD: 1.5902 sec.
   Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.2438 sec, LOAD: 
0.9825 sec.
   Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.3199 sec, LOAD: 
2.5883 sec.
   
   
   Package used (Python/R/Scala/Julia):
   Im using Python
   
   ## Error Message:
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/block.py",
 line 360, in __call__
       return self.forward(*args)
     File "/home/samh/dev/MXNet-Gluon-Style-Transfer/net.py", line 215, in 
forward
       return self.model(input)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/block.py",
 line 360, in __call__
       return self.forward(*args)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/nn/basic_layers.py",
 line 53, in forward
       x = block(x)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/block.py",
 line 360, in __call__
       return self.forward(*args)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/nn/basic_layers.py",
 line 53, in forward
       x = block(x)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/block.py",
 line 360, in __call__
       return self.forward(*args)
     File "/home/samh/dev/MXNet-Gluon-Style-Transfer/net.py", line 123, in 
forward
       x = self.pad(x)
     File 
"/asset/common/software/thirdparty/mxnet/1.0.0-build1/python2.7/mxnet/gluon/block.py",
 line 360, in __call__
       return self.forward(*args)
     File "/home/samh/dev/MXNet-Gluon-Style-Transfer/net.py", line 44, in 
forward
       return F.pad(x, mode='reflect', pad_width=self.pad_width)
     File "<string>", line 112, in pad
   AssertionError: Argument data must have NDArray type, but got <Symbol data>
   
   ## Minimum reproducible example
   Adding the following lines
   `  x = mx.sym.var('data')
       y = style_model(x)
       y_json = y.tojson()
       y.save("MODEL.json")
       y.save_params("MODEL.params")`
   
   to the end of the evaluate function of
   
https://github.com/apache/incubator-mxnet/blob/master/example/gluon/style_transfer/net.py
   
   and running
   python main.py eval
   
   with argument to a valid model, style image and output image
   
   ## Steps to reproduce
   
   As described edit the source file 
https://github.com/apache/incubator-mxnet/blob/master/example/gluon/style_transfer/net.py
 to allow for converting the Net model to a symbolic model , try to save the 
symbolic model, it fails because hybrid_forward functions are not implemented.
   
   ## What have you tried to solve it?
   
   I have tried replacing the forward functions with hybrid_forward functions 
but have been unable to convert the Inspiration(HybridBlock)
   
   This would provide an excellent example of training in Python and deploying 
in C++ if possible

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to