ó šÄïYc @ s dZddlmZddddddd d d d g Zd dlmZd dlmZddlm Z ddl m Z de fd„ƒYZ idddddgdddddgfd6dddddgdddddgfd6dddddgdddddgfd6ddd d d gdddddgfd6Z eeƒd„Zd„Zd „Zd!„Zd"„Zd#„Zd$„Zd%„Zd&„Zd'S((sVGG, implemented in Gluon.iÿÿÿÿ(tdivisiontVGGtvgg11tvgg13tvgg16tvgg19tvgg11_bntvgg13_bntvgg16_bntvgg19_bntget_vggi(tcpu(tXavieri(t HybridBlock(tnncB 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 s+tt|ƒj|t|ƒt|ƒks4t‚|jƒå|j|||ƒ|_tj ddƒ|_ |j j tj ddddddd ƒƒ|j j tj d d ƒƒ|j j tj ddddddd ƒƒ|j j tj d d ƒƒ|j j tj |dddd ƒƒWdQXdS( Ntprefixtit activationtrelutweight_initializertnormaltbias_initializertzerostrategà?(tsuperRt__init__tlentAssertionErrort name_scopet_make_featurestfeaturesRtHybridSequentialt classifiertaddtDensetDropout(tselftlayerstfilterstclassest batch_normtkwargs((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyR0s    cC sÜtjddƒ}xÃt|ƒD]µ\}}xt|ƒD]}|jtj||dddddtdd d d d d ƒddƒƒ|r¡|jtjƒƒn|jtjdƒƒq8W|jtj dd ƒƒqW|S(NRRt kernel_sizeitpaddingiRtrnd_typetgaussiant factor_typetoutt magnitudeiRRRtstrides( RRt enumeratetrangeR!tConv2DR t BatchNormt Activationt MaxPool2D(R$R%R&R(t featurizertitnumt_((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyRBs"   cC s"|j|ƒ}|j|ƒ}|S(N(RR (R$tFtx((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pythybrid_forwardQs(t__name__t __module__t__doc__tFalseRRR>(((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyR!s iii@i€iii i iic K s}t|\}}t|||}|ryddlm}|jdƒrMdnd}|j|d||fƒ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. i(tget_model_fileR(t_bnRsvgg%d%stctx(tvgg_specRt model_storeRCtgett load_params( t num_layerst pretrainedRER)R%R&tnetRCtbatch_norm_suffix((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyR _s &cK s td|S(siVGG-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. i (R (R)((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyRts cK s td|S(siVGG-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. i (R (R)((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyRs cK s td|S(siVGG-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. i(R (R)((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyRŽs cK s td|S(siVGG-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. i(R (R)((s@build/bdist.linux-armv7l/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. R(i (tTrueR (R)((s@build/bdist.linux-armv7l/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. R(i (RNR (R)((s@build/bdist.linux-armv7l/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. R(i(RNR (R)((s@build/bdist.linux-armv7l/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. R(i(RNR (R)((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyR Õs N(RAt __future__Rt__all__tcontextR t initializerR tblockR RRRRFRBR RRRRRRRR (((s@build/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/vision/vgg.pyts.   7.++.