σ šΔοYc@s\dZddlmZmZddlmZdefd„ƒYZdefd„ƒYZdS( s*Custom neural network layers in model_zoo.i(tBlockt HybridBlock(t_indenttHybridConcurrentcBs8eZdZddd„Zd„Zd„Zd„ZRS(s4Lays `HybridBlock`s concurrently. Example:: net = HybridConcurrent() # use net's name_scope to give child Blocks appropriate names. with net.name_scope(): net.add(nn.Dense(10, activation='relu')) net.add(nn.Dense(20)) net.add(Identity()) cCs,tt|ƒjd|d|ƒ||_dS(Ntprefixtparams(tsuperRt__init__t concat_dim(tselfRRR((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyR%scCs|j|ƒdS(sAdds block on top of the stack.N(tregister_child(R tblock((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pytadd)scCsIg}x$|jD]}|j||ƒƒqW|jd|j|Œ}|S(Ntdim(t _childrentappendtconcatR(R tFtxtoutR ((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pythybrid_forward-s c Csƒd}djgt|jƒD]B\}}t|tƒrdjd|dt|jƒdƒƒ^qƒ}|jd|jj d|ƒS( Ns{name}( {modstr} )s s ({key}): {block}tkeyR itnametmodstr( tjoint enumerateRt isinstanceRtformatRt__repr__t __class__t__name__(R tsRR R((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyR4s  ?N(Rt __module__t__doc__tNoneRR RR(((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyRs    tIdentitycBs&eZdZddd„Zd„ZRS(s¦Block that passes through the input directly. This layer is often used in conjunction with HybridConcurrent block for residual connection. Example:: net = HybridConcurrent() # use net's name_scope to give child Blocks appropriate names. with net.name_scope(): net.add(nn.Dense(10, activation='relu')) net.add(nn.Dense(20)) net.add(Identity()) cCs#tt|ƒjd|d|ƒdS(NRR(RR#R(R RR((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyRMscCs|S(N((R RR((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyRPsN(RR R!R"RR(((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyR#>sN(R!R RRtutilsRRR#(((sCbuild/bdist.linux-armv7l/egg/mxnet/gluon/model_zoo/custom_layers.pyts%