ó ùµÈ[c @ sÔdZddlmZddddddd d d d g Zdd lZddlmZddlmZddl m Z ddl m Z ddl m Z de fd„ƒYZidddddgdddddgfd6dddddgdddddgfd6dddddgdddddgfd6dddddgdddddgfd6Zeeƒejje jƒd ƒd!„Zd"„Zd#„Zd$„Zd%„Zd&„Zd'„Zd(„Zd)„Zd S(*sVGG, implemented in Gluon.iÿÿÿÿ(tdivisiontVGGtvgg11tvgg13tvgg16tvgg19tvgg11_bntvgg13_bntvgg16_bntvgg19_bntget_vggNi(tcpu(tXavieri(t HybridBlock(tnn(tbasecB s/eZdZded„Zd„Zd„ZRS(söVGG model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- layers : list of int Numbers of layers in each feature block. filters : list of int Numbers of filters in each feature block. List length should match the layers. classes : int, default 1000 Number of classification classes. batch_norm : bool, default False Use batch normalization. ièc K stt|ƒj|t|ƒt|ƒks4t‚|jƒÉ|j|||ƒ|_|jjt j dddddddƒƒ|jjt j dd ƒƒ|jjt j dddddddƒƒ|jjt j dd ƒƒt j |ddddƒ|_ WdQXdS( Nit activationtrelutweight_initializertnormaltbias_initializertzerostrategà?( tsuperRt__init__tlentAssertionErrort name_scopet_make_featurestfeaturestaddRtDensetDropouttoutput(tselftlayerstfilterstclassest batch_normtkwargs((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR3s    cC sÜtjddƒ}xÃt|ƒD]µ\}}xt|ƒD]}|jtj||dddddtdd d d d d ƒddƒƒ|r¡|jtjƒƒn|jtjdƒƒq8W|jtj dd ƒƒqW|S(Ntprefixtt kernel_sizeitpaddingiRtrnd_typetgaussiant factor_typetoutt magnitudeiRRRtstrides( RtHybridSequentialt enumeratetrangeRtConv2DR t BatchNormt Activationt MaxPool2D(R"R#R$R&t featurizertitnumt_((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyRDs"   cC s"|j|ƒ}|j|ƒ}|S(N(RR!(R"tFtx((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pythybrid_forwardSs(t__name__t __module__t__doc__tFalseRRR?(((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR$s iii@i€iii i iitmodelsc K sƒt|\}}t|||}|rddlm}|jdƒrMdnd} |j|d|| fd|ƒd|ƒn|S( s+VGG model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- num_layers : int Number of layers for the variant of densenet. Options are 11, 13, 16, 19. pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default $MXNET_HOME/models Location for keeping the model parameters. i(tget_model_fileR&t_bnR)svgg%d%stroottctx(tvgg_specRt model_storeREtgettload_parameters( t num_layerst pretrainedRHRGR'R#R$tnetREtbatch_norm_suffix((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR ascK s td|S(sÉVGG-11 model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. i (R (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyRzs cK s td|S(sÉVGG-13 model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. i (R (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR‰s cK s td|S(sÉVGG-16 model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. i(R (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR˜s cK s td|S(sÉVGG-19 model from the `"Very Deep Convolutional Networks for Large-Scale Image Recognition" `_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. i(R (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR§s cK st|d`_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. R&i (tTrueR (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR¶s cK st|d`_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. R&i (RQR (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyRÇs cK st|d`_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. R&i(RQR (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyRØs cK st|d`_ paper. Parameters ---------- pretrained : bool, default False Whether to load the pretrained weights for model. ctx : Context, default CPU The context in which to load the pretrained weights. root : str, default '$MXNET_HOME/models' Location for keeping the model parameters. R&i(RQR (R'((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyR és (RBt __future__Rt__all__tostcontextR t initializerR tblockR R)RRRRIRCtpathtjointdata_dirR RRRRRRRR (((s`/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/model_zoo/vision/vgg.pyts4    6.++. !