ó šÄïYc@@sdZddlmZyddlmZWn!ek rMddlmZnXddl Z ddl Z ddl m Z ddl ZddlZddlZddlmZmZddlmZmZmZmZmZdd lmZmZmZmZdd lmZm Z m!Z!m"Z"dd l#m$Z$dd l%m&Z&m'Z'm(Z(m)Z)dd l*m+Z+ddl,m-Z-ddl.m/Z0ddl1m2Z2ddl3m4Z4y²e5ej6j7de8ƒƒdkrëddl9m:Z:m;Z;ddl9m<Z<ndej=ddfkr)ddl>m:Z:m;Z;ddl>m<Z<n&ddl?m:Z:m;Z;ddl?m<Z<Wngek r¹e5ej6j7de@ƒƒdkredƒ‚nddl9m:Z:m;Z;ddl9m<Z<nXde:fd„ƒYZAeBeBeBeBeBeBd„ZCeCZDd„ZEd„ZFd„ZGd„ZHd„ZId „ZJd!„ZKeBd"„ZLeBd#„ZMeBd$„ZNeBd%deBeBd&„ZOd'„ZPd(„ZQeQeAd)ƒdS(*s$Symbolic configuration API of MXNet.i(tabsolute_import(tsliceN(tNumberi(t_LIBt numeric_types(tc_arraytc_strtmx_uinttpy_strt string_types(t NDArrayHandletExecutorHandlet SymbolHandletOpHandle(t check_callt MXNetErrortNotImplementedForSymbolt_Null(tContext(tNDArrayt_DTYPE_NP_TO_MXt_DTYPE_MX_TO_NPt _GRAD_REQ_MAP(t NameManager(tExecutor(t_symbol_internal(t AttrScope(t _build_doctMXNET_ENABLE_CYTHON(t SymbolBaset_set_symbol_class(t_symbol_creatoritMXNET_ENFORCE_CYTHONs9Cython Module cannot be loaded but MXNET_ENFORCE_CYTHON=1tSymbolcB@s¢eZdZgZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d „Z#d!„Z$d"„Z%d#„Z&e'd$„ƒZ(d%„Z)e*d&„Z+d'„Z,d(„Z-d)„Z.d*„Z/d+„Z0d,„Z1d-„Z2d.„Z3d/„Z4d0„Z5d1„Z6d2„Z7d3„Z8d4„Z9d5„Z:e;d6„ƒZ<d7dEdEdEdEdEd8„Z>dEd7dEdEdEd9„Z?d:„Z@dEd;„ZAd<„ZBd=„ZCd>„ZDd?„ZEd@„ZFdA„ZGdB„ZHdC„ZIdD„ZJRS(Fs&Symbol is symbolic graph of the mxnet.cC@sf|j}|dkrNdjg|D]}|j^q"ƒ}d|jj|fSd|jj|fSdS(s+Gets a string representation of the symbol.s, s<%s group [%s]>s<%s %s>N(tnametNonetjoint __class__t__name__(tselfR"ti((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__repr__Is   %c@s‡fd†ˆjƒDƒS(sæReturns a generator object of symbol. One can loop through the returned object list to get outputs. Example usage: ---------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.Variable('b') >>> c = a+b >>> d = mx.sym.Variable('d') >>> e = d+c >>> out = e.get_children() >>> out >>> for i in out: ... i ... c3@s|]}ˆ|VqdS(N((t.0R((R'(s,build/bdist.linux-armv7l/egg/mxnet/symbol.pys gs(t list_outputs(R'((R's,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__iter__RscC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s}x.__add__(y) <=> x+y Scalar input is supported. Broadcasting is not supported. Use `broadcast_add` instead. tscalarstype %s not supportedN( t isinstanceR!t _internalt_PlusRt _PlusScalart TypeErrortstrttype(R'tother((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__add__is cC@st|jd|dƒ‚dS(Ns+=i(Rt__iadd__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR7uscC@s |j|ƒS(N(R6(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__radd__xscC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s}x.__sub__(y) <=> x-y Scalar input is supported. Broadcasting is not supported. Use `broadcast_sub` instead. R-stype %s not supportedN( R.R!R/t_MinusRt _MinusScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__sub__{s cC@st|jd|ƒ‚dS(Ns-=(Rt__isub__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR<‡scC@sBt|tƒr"tj|d|ƒStdtt|ƒƒƒ‚dS(s1x.__rsub__(y) <=> y-x Only `NDArray` is supported for now. Example usage: ---------- >>> x = mx.nd.ones((2,3))*3 >>> y = mx.nd.ones((2,3)) >>> x.__rsub__(y).asnumpy() array([[-2., -2., -2.], [-2., -2., -2.]], dtype=float32) R-stype %s not supportedN(R.RR/t _RMinusScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__rsub__Šs cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s}x.__mul__(y) <=> x*y Scalar input is supported. Broadcasting is not supported. Use `broadcast_mul` instead. R-stype %s not supportedN( R.R!R/t_MulRt _MulScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__mul__œs cC@st|jd|ƒ‚dS(Ns*=(Rt__imul__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRB¨scC@s |j|ƒS(N(RA(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__rmul__«scC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s}x.__div__(y) <=> x/y Scalar input is supported. Broadcasting is not supported. Use `broadcast_div` instead. R-stype %s not supportedN( R.R!R/t_DivRt _DivScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__div__®s cC@sBt|tƒr"tj|d|ƒStdtt|ƒƒƒ‚dS(sax.__rdiv__(y) <=> y/x Only `NDArray` is supported for now. Example usage: ---------- >>> x = mx.nd.ones((2,3))*3 >>> y = mx.nd.ones((2,3)) >>> x.__rdiv__(y).asnumpy() array([[ 0.33333334, 0.33333334, 0.33333334], [ 0.33333334, 0.33333334, 0.33333334]], dtype=float32) R-stype %s not supportedN(R.RR/t _RDivScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__rdiv__ºs cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s}x.__mod__(y) <=> x%y Scalar input is supported. Broadcasting is not supported. Use `broadcast_mod` instead. R-stype %s not supportedN( R.R!R/t_ModRt _ModScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__mod__Ìs cC@sBt|tƒr"tj|d|ƒStdtt|ƒƒƒ‚dS(s.x.__rmod__(y) <=> y%x Only `NDArray` is supported for now. Example usage: ---------- >>> x = mx.nd.ones((2,3))*3 >>> y = mx.nd.ones((2,3)) >>> x.__rmod__(y).asnumpy() array([[ 1., 1., 1., [ 1., 1., 1., dtype=float32) R-stype %s not supportedN(R.RR/t _RModScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__rmod__Øs cC@st|jd|ƒ‚dS(Ns/=(Rt__idiv__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRNêscC@s |j|ƒS(N(RF(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt __truediv__íscC@s |j|ƒS(N(RH(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt __rtruediv__ðscC@st|jd|ƒ‚dS(Ns/=(Rt __itruediv__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRQóscC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s~x.__pow__(y) <=> x**y Scalar input is supported. Broadcasting is not supported. Use `broadcast_pow` instead. R-stype %s not supportedN( R.R!R/t_PowerRt _PowerScalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__pow__ös cC@st|jd|ƒ‚dS(Nsy**x(Rt__rpow__(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRUscC@s |jdƒS(s×x.__neg__() <=> -x Numerical negative, element-wise. Example usage: ---------- >>> a = mx.sym.Variable('a') >>> a >>> -a >>> a_neg = a.__neg__() >>> c = a_neg*b >>> ex = c.eval(ctx=mx.cpu(), a=mx.nd.ones([2,3]), b=mx.nd.ones([2,3])) >>> ex[0].asnumpy() array([[-1., -1., -1.], [-1., -1., -1.]], dtype=float32) gð¿(RA(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__neg__scC@s |jdƒS(N(t __deepcopy__R#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__copy__scC@s5tƒ}ttj|jtj|ƒƒƒt|ƒS(s)Returns a deep copy of the input object. This function returns a deep copy of the input object including the current state of all its parameters such as weights, biases, etc. Any changes made to the deep copy do not reflect in the original object. Example usage: ---------- >>> import copy >>> data = mx.sym.Variable('data') >>> data_1 = copy.deepcopy(data) >>> data_1 = 2*data >>> data_1.tojson() >>> data_1 is data # Data got modified False (R RRt MXSymbolCopythandletctypestbyrefR!(R't_RZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRWs cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(sx.__eq__(y) <=> x==y Scalar input is supported. Broadcasting is not supported. Use `broadcast_equal` instead. R-stype %s not supportedN( R.R!R/t_equalRt _equal_scalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__eq__4s cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(sƒx.__ne__(y) <=> x!=y Scalar input is supported. Broadcasting is not supported. Use `broadcast_not_equal` instead. R-stype %s not supportedN( R.R!R/t _not_equalRt_not_equal_scalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__ne__@s cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s€x.__gt__(y) <=> x>y Scalar input is supported. Broadcasting is not supported. Use `broadcast_greater` instead. R-stype %s not supportedN( R.R!R/t_greaterRt_greater_scalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__gt__Ls cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(s‡x.__ge__(y) <=> x>=y Scalar input is supported. Broadcasting is not supported. Use `broadcast_greater_equal` instead. R-stype %s not supportedN( R.R!R/t_greater_equalRt_greater_equal_scalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__ge__Xs cC@sat|tƒrtj||ƒSt|tƒrAtj|d|ƒStdtt|ƒƒƒ‚dS(sx.__lt__(y) <=> x x<=y Scalar input is supported. Broadcasting is not supported. Use `broadcast_lesser_equal` instead. R-stype %s not supportedN( R.R!R/t _lesser_equalRt_lesser_equal_scalarR2R3R4(R'R5((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__le__ps cC@s5|j}|dk r&i|jƒd6Sidd6SdS(NRZ(RZR#ttojson(R'RZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt __getstate__|s  cC@sc|d}|dk rV|}tƒ}ttjt|ƒtj|ƒƒƒ||_n d|_dS(NRZ( R#R RRtMXSymbolCreateFromJSONRR[R\RZ(R'tstateRZtjson_str((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt __setstate__ƒs   % cO@s |jƒ}|j||Ž|S(sTComposes symbol using inputs. x.__call__(y, z) <=> x(y,z) This function internally calls `_compose` to compose the symbol and returns the composed symbol. Example usage: ---------- >>> data = mx.symbol.Variable('data') >>> net1 = mx.symbol.FullyConnected(data=data, name='fc1', num_hidden=10) >>> net2 = mx.symbol.FullyConnected(name='fc3', num_hidden=10) >>> composed = net2(fc3_data=net1, name='composed') >>> composed >>> called = net2.__call__(fc3_data=net1, name='composed') >>> called Parameters ---------- args: Positional arguments. kwargs: Keyword arguments. Returns ------- The resulting symbol. (RXt_compose(R'targstkwargsts((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt__call__Žs c O@s|jddƒ}|r't|ƒ}nt|ƒdkrZt|ƒdkrZtdƒ‚nx,|D]$}t|tƒsatdƒ‚qaqaWx2|jƒD]$}t|tƒs–tdƒ‚q–q–Wt|ƒt|ƒ}t|ƒdkr?tt j g|D]}t|ƒ^qöƒ}tt g|jƒD]} | j ^q$ƒ}n+d}tt g|D]} | j ^qRƒ}t tj|j ||||ƒƒdS(sÅComposes symbol using inputs. x._compose(y, z) <=> x(y,z) This function mutates the current symbol. Example usage: ---------- >>> data = mx.symbol.Variable('data') >>> net1 = mx.symbol.FullyConnected(data=data, name='fc1', num_hidden=10) >>> net2 = mx.symbol.FullyConnected(name='fc3', num_hidden=10) >>> net2 >>> net2._compose(fc3_data=net1, name='composed') >>> net2 Parameters ---------- args: Positional arguments. kwargs: Keyword arguments. Returns ------- The resulting symbol. R"isecompose only accept input Symbols either as positional or keyword arguments, not boths$Compose expect `Symbol` as argumentsN(tpopR#RtlenR2R.R!tvaluesRR[tc_char_pR RZRRtMXSymbolCompose( R'RwRxR"targtvaltnum_argstkeytkeysRy((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRv²s($  +.% c C@s°|jƒ}t|tƒr¨|jdkr0dn|j}|jdkrTt|ƒn|j}|jdkrrdn|j}tgt |||ƒD]}||^q‘ƒSt|t ƒr6d}xNt |ƒD]@\}}||krÊ|dk rt d|ƒ‚n|}qÊqÊW|dkr-t d|ƒ‚n|}nt|t ƒsTtdƒ‚n|t|ƒkrot‚ntƒ} ttj|jt|ƒtj| ƒƒƒtd| ƒS(sQx.__getitem__(i) <=> x[i] Returns a sliced view of the input symbol. Example usage: ---------- >>> a = mx.sym.var('a') >>> a.__getitem__(0) >>> a[0] Parameters ---------- index : int or str Indexing key iis)There are multiple outputs with name "%s"s)Cannot find output that matches name "%s"s6Symbol only support integer index to fetch i-th outputRZN(R+R.tpy_slicetstartR#tstopR|tsteptGrouptrangeR t enumeratet ValueErrortintR2t IndexErrorR RRtMXSymbolGetOutputRZRR[R\R!( R'tindext output_namesR†R‡RˆR(tidxR"RZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt __getitem__és0 $-        "cC@sjtjƒ}tjƒ}ttj|jtj|ƒtj|ƒƒƒ|jdkrbt |jƒSdSdS(sÚGets name string from the symbol, this function only works for non-grouped symbol. Returns ------- value : str The name of this symbol, returns ``None`` for grouped symbol. iN( R[R~tc_intRRtMXSymbolGetNameRZR\tvalueRR#(R'trettsuccess((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR"s   % cC@sstjƒ}tjƒ}ttj|jt|ƒtj|ƒtj|ƒƒƒ|j dkrkt |j ƒSdSdS(s.Returns the attribute string for corresponding input key from the symbol. This function only works for non-grouped symbols. Example usage: ---------- >>> data = mx.sym.Variable('data', attr={'mood': 'angry'}) >>> data.attr('mood') 'angry' Parameters ---------- key : str The key corresponding to the desired attribute. Returns ------- value : str The desired attribute value, returns ``None`` if the attribute does not exist. iN( R[R~R”RRtMXSymbolGetAttrRZRR\R–RR#(R'RƒR—R˜((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytattr*s   . c@s„|rtdƒ‚ntƒ}tjtjƒƒ‰tj}t||jtj |ƒtj ˆƒƒƒ‡fd†t |j ƒDƒS(sOGets all attributes from the symbol. Example usage: ---------- >>> data = mx.sym.Variable('data', attr={'mood': 'angry'}) >>> data.list_attr() {'mood': 'angry'} Returns ------- ret : Dict of str to str A dictionary mapping attribute keys to values. sWSymbol.list_attr with recursive=True has been deprecated. Please use attr_dict instead.c@s9i|]/}tˆ|ddƒtˆ|dƒ“qS(ii(R(R*R((tpairs(s,build/bdist.linux-armv7l/egg/mxnet/symbol.pys ]s ( tDeprecationWarningRR[tPOINTERR~RtMXSymbolListAttrShallowRRZR\RŠR–(R't recursivetsizetf_handle((R›s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt list_attrHs  +c C@sØtƒ}tjtjƒƒ}tj}t||jtj|ƒtj|ƒƒƒi}xyt |j ƒD]h}t ||dƒj dƒ\}}t ||ddƒ}||krÂi||>> a = mx.sym.Variable('a', attr={'a1':'a2'}) >>> b = mx.sym.Variable('b', attr={'b1':'b2'}) >>> c = a+b >>> c.attr_dict() {'a': {'a1': 'a2'}, 'b': {'b1': 'b2'}} Returns ------- ret : Dict of str to dict There is a key in the returned dict for every child with non-empty attribute set. For each symbol, the name of the symbol is its key in the dict and the correspond value is that symbol's attribute list (itself a dictionary). it$i( RR[RR~RtMXSymbolListAttrRRZR\RŠR–Rtsplit( R'R R›R¡R—R(R"RƒR((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt attr_dict_s  +#  cK@smxf|jƒD]X\}}t|tƒs7tdƒ‚nttj|jt|ƒtt |ƒƒƒƒq WdS(sSets an attribute of the symbol. For example. A._set_attr(foo="bar") adds the mapping ``"{foo: bar}"`` to the symbol's attribute dictionary. Parameters ---------- **kwargs The attributes to set s#Set Attr only accepts string valuesN( titemsR.R RŒRRtMXSymbolSetAttrRZRR3(R'RxRƒR–((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt _set_attr~s  cC@s8tƒ}ttj|jtj|ƒƒƒtd|ƒS(skGets a new grouped symbol `sgroup`. The output of `sgroup` is a list of outputs of all of the internal nodes. Consider the following code: Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> d = c.get_internals() >>> d >>> d.list_outputs() ['a', 'b', '_plus4_output'] Returns ------- sgroup : Symbol A symbol group containing all internal and leaf nodes of the computation graph used to compute the symbol. RZ(R RRtMXSymbolGetInternalsRZR[R\R!(R'RZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt get_internalss  cC@sZtƒ}ttj|jtj|ƒƒƒtd|ƒ}t|j ƒƒdkrVdS|S(sµGets a new grouped symbol whose output contains inputs to output nodes of the original symbol. Example usage: ---------- >>> x = mx.sym.Variable('x') >>> y = mx.sym.Variable('y') >>> z = mx.sym.Variable('z') >>> a = y+z >>> b = x+a >>> b.get_children() >>> b.get_children().list_outputs() ['x', '_plus10_output'] >>> b.get_children().get_children().list_outputs() ['y', 'z'] Returns ------- sgroup : Symbol or None The children of the head node. If the symbol has no inputs then ``None`` will be returned. RZiN( R RRtMXSymbolGetChildrenRZR[R\R!R|R+R#(R'RZR—((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt get_children«s  cC@sytjƒ}tjtjƒƒ}ttj|jtj|ƒtj|ƒƒƒgt |j ƒD]}t ||ƒ^q_S(szLists all the arguments in the symbol. Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> c.list_arguments ['a', 'b'] Returns ------- args : list of string List containing the names of all the arguments required to compute the symbol. ( R[tc_uintRR~RRtMXSymbolListArgumentsRZR\RŠR–R(R'R tsarrR(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytlist_argumentsËs   %cC@sytjƒ}tjtjƒƒ}ttj|jtj|ƒtj|ƒƒƒgt |j ƒD]}t ||ƒ^q_S(sõLists all the outputs in the symbol. Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> c.list_outputs() ['_plus12_output'] Returns ------- list of str List of all the outputs. For most symbols, this list contains only the name of this symbol. For symbol groups, this is a list with the names of all symbols in the group. ( R[R®RR~RRtMXSymbolListOutputsRZR\RŠR–R(R'R R°R(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR+ás   %cC@sytjƒ}tjtjƒƒ}ttj|jtj|ƒtj|ƒƒƒgt |j ƒD]}t ||ƒ^q_S(sSLists all the auxiliary states in the symbol. Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> c.list_auxiliary_states() [] Example of auxiliary states in `BatchNorm`. >>> data = mx.symbol.Variable('data') >>> weight = mx.sym.Variable(name='fc1_weight') >>> fc1 = mx.symbol.FullyConnected(data = data, weight=weight, name='fc1', num_hidden=128) >>> fc2 = mx.symbol.BatchNorm(fc1, name='batchnorm0') >>> fc2.list_auxiliary_states() ['batchnorm0_moving_mean', 'batchnorm0_moving_var'] Returns ------- aux_states : list of str List of the auxiliary states in input symbol. Notes ----- Auxiliary states are special states of symbols that do not correspond to an argument, and are not updated by gradient descent. Common examples of auxiliary states include the `moving_mean` and `moving_variance` in `BatchNorm`. Most operators do not have auxiliary states. ( R[R®RR~RRtMXSymbolListAuxiliaryStatesRZR\RŠR–R(R'R R°R(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytlist_auxiliary_statesús  %cC@s|tjƒ}tjtjƒƒ}ttj|jdtj|ƒtj|ƒƒƒgt |j ƒD]}t ||ƒ^qbS(søLists all arguments and auxiliary states of this Symbol. Returns ------- inputs : list of str List of all inputs. Examples -------- >>> bn = mx.sym.BatchNorm(name='bn') >>> bn.list_arguments() ['bn_data', 'bn_gamma', 'bn_beta'] >>> bn.list_auxiliary_states() ['bn_moving_mean', 'bn_moving_var'] >>> bn.list_inputs() ['bn_data', 'bn_gamma', 'bn_beta', 'bn_moving_mean', 'bn_moving_var'] i( R[R®RR~RRtNNSymbolListInputNamesRZR\RŠR–R(R'R R°R(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt list_inputs s   (cO@sÐt|ƒdkr3t|ƒdkr3tdƒ‚ng}t|ƒdkrÉd}xÝ|D]j}|dk rµtj|ƒj}|tkr¡tdttƒƒ‚n|j t|ƒqX|j dƒqXWnhg}x_|j ƒD]Q\}}tj|ƒj}|tkrÜ|j t |ƒƒ|j t|ƒqÜqÜWt ƒ}t jt jƒƒ} t ƒ} t jt jƒƒ} t ƒ} t jt jƒƒ} t jƒ}ttj|jt t|ƒƒtt j|ƒtt j|ƒt j|ƒt j| ƒt j| ƒt j| ƒt j| ƒt j| ƒt j|ƒƒ ƒ|jdkrÈgt|jƒD]}t| |^qM}gt| jƒD]}t| |^qw}gt| jƒD]}t| |^q¡}|||fSdSdS(sáInfers the type of all arguments and all outputs, given the known types for some arguments. This function takes the known types of some arguments in either positional way or keyword argument way as input. It returns a tuple of `None` values if there is not enough information to deduce the missing types. Inconsistencies in the known types will cause an error to be raised. Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> arg_types, out_types, aux_types = c.infer_type(a='float32') >>> arg_types [, ] >>> out_types [] >>> aux_types [] Parameters ---------- *args : Type of known arguments in a positional way. Unknown type can be marked as None. **kwargs : Keyword arguments of known types. Returns ------- arg_types : list of numpy.dtype or None List of argument types. The order is same as the order of list_arguments(). out_types : list of numpy.dtype or None List of output types. The order is same as the order of list_outputs(). aux_types : list of numpy.dtype or None List of auxiliary state types. The order is same as the order of list_auxiliary_states(). is]Can only specify known argument types either by positional or kwargs way.sArgument need to be one of iÿÿÿÿN(NNN(R|RŒR#t_numpytdtypeR4RR2R3tappendR§RRR[RR”RRtMXSymbolInferTypeRZRR~R\R–RŠR(R'RwRxtsdataR„Rytktvt arg_type_sizet arg_type_datat out_type_sizet out_type_datat aux_type_sizet aux_type_datatcompleteR(t arg_typest out_typest aux_types((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt infer_type8sX-$                *** cO@szy|jt||Ž}|ddkrý|jt||Ž\}}}|jƒ}g}xwt||ƒD]f\}} | s‹tj| ƒ rht|ƒdkr®|j dƒPn|j d|t | ƒfƒqhqhWt j ddddj |ƒd d ƒn|SWnqtk rud GHx)t|ƒD]\} } d | | fGHq$Wx)|jƒD]\} } d | | fGHqPW‚nXdS(sBInfers the shapes of all arguments and all outputs given the known shapes of some arguments. This function takes the known shapes of some arguments in either positional way or keyword argument way as input. It returns a tuple of `None` values if there is not enough information to deduce the missing shapes. Example usage: ---------- >>> a = mx.sym.var('a') >>> b = mx.sym.var('b') >>> c = a + b >>> arg_shapes, out_shapes, aux_shapes = c.infer_shape(a=(3,3)) >>> arg_shapes [(3L, 3L), (3L, 3L)] >>> out_shapes [(3L, 3L)] >>> aux_shapes [] >>> c.infer_shape(a=(0,3)) # 0s in shape means unknown dimensions. So, returns None. (None, None, None) Inconsistencies in the known shapes will cause an error to be raised. See the following example: >>> data = mx.sym.Variable('data') >>> out = mx.sym.FullyConnected(data=data, name='fc1', num_hidden=1000) >>> out = mx.sym.Activation(data=out, act_type='relu') >>> out = mx.sym.FullyConnected(data=out, name='fc2', num_hidden=10) >>> weight_shape= (1, 100) >>> data_shape = (100, 100) >>> out.infer_shape(data=data_shape, fc1_weight=weight_shape) Error in operator fc1: Shape inconsistent, Provided=(1,100), inferred shape=(1000,100) Parameters ---------- *args : Shape of arguments in a positional way. Unknown shape can be marked as None. **kwargs : Keyword arguments of the known shapes. Returns ------- arg_shapes : list of tuple or None List of argument shapes. The order is same as the order of list_arguments(). out_shapes : list of tuple or None List of output shapes. The order is same as the order of list_outputs(). aux_shapes : list of tuple or None List of auxiliary state shapes. The order is same as the order of list_auxiliary_states(). ii s...s%s: %ss0Cannot decide shape for the following arguments s((0s in shape means unknown dimensions). s#Consider providing them as input: s t stacklevelisinfer_shape error. Arguments:s #%d: %ss %s: %sN(t_infer_shape_impltFalseR#tTrueR±tzipR·tprodR|R¹R3twarningstwarnR$RR‹R§(R'RwRxtrest arg_shapesR]t arg_namestunknownsR"tshapeR(R€R¼R½((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt infer_shape™s.8  $  cO@s|jt||ŽS(sžInfers the shape partially. This functions works the same way as `infer_shape`, except that this function can return partial results. In the following example, information about fc2 is not available. So, `infer_shape` will return a tuple of `None` values but `infer_shape_partial` will return partial values. Example usage: ---------- >>> data = mx.sym.Variable('data') >>> prev = mx.sym.Variable('prev') >>> fc1 = mx.sym.FullyConnected(data=data, name='fc1', num_hidden=128) >>> fc2 = mx.sym.FullyConnected(data=prev, name='fc2', num_hidden=128) >>> out = mx.sym.Activation(data=mx.sym.elemwise_add(fc1, fc2), act_type='relu') >>> out.list_arguments() ['data', 'fc1_weight', 'fc1_bias', 'prev', 'fc2_weight', 'fc2_bias'] >>> out.infer_shape(data=(10,64)) (None, None, None) >>> out.infer_shape_partial(data=(10,64)) ([(10L, 64L), (128L, 64L), (128L,), (), (), ()], [(10L, 128L)], []) >>> # infers shape if you give information about fc2 >>> out.infer_shape(data=(10,64), prev=(10,128)) ([(10L, 64L), (128L, 64L), (128L,), (10L, 128L), (128L, 128L), (128L,)], [(10L, 128L)], []) Parameters ---------- *args : Shape of arguments in a positional way. Unknown shape can be marked as None **kwargs : Keyword arguments of known shapes. Returns ------- arg_shapes : list of tuple or None List of argument shapes. The order is same as the order of list_arguments(). out_shapes : list of tuple or None List of output shapes. The order is same as the order of list_outputs(). aux_shapes : list of tuple or None List of auxiliary state shapes. The order is same as the order of list_auxiliary_states(). (RÊRÌ(R'RwRx((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytinfer_shape_partialës/cO@s©t|ƒdkr3t|ƒdkr3tdƒ‚ng}dg}t|ƒdkr×d}xþt|ƒD]i\}}|dk r½t|tƒs­td|t|ƒfƒ‚n|j|ƒn|j t|ƒƒqgWn„g}x{|j ƒD]m\} } t| tƒs$td| t| ƒfƒ‚n|j t | ƒƒ|j| ƒ|j t|ƒƒqêWt ƒ} t jt ƒƒ} t jt jt ƒƒƒ} t ƒ}t jt ƒƒ}t jt jt ƒƒƒ}t ƒ}t jt ƒƒ}t jt jt ƒƒƒ}t jƒ}|rtj}n tj}t||jt t|ƒdƒtt j|ƒtt |ƒtt |ƒt j| ƒt j| ƒt j| ƒt j|ƒt j|ƒt j|ƒt j|ƒt j|ƒt j|ƒt j|ƒƒƒ|jdkr¡gt| jƒD]}t| || | ƒ^q}gt|jƒD]}t|||| ƒ^q<}gt|jƒD]}t|||| ƒ^qp}|||fSdSdS(s:The actual implementation for calling shape inference API.is^Can only specify known argument shapes either by positional or kwargs way.s;Arguments need to be shapes (tuple), but argument %d is %s.s4Arguments need to be shapes (tuple), but '%s' is %s.iN(NNN(R|RŒR#R‹R.ttupleR2R4textendR¹R§RRR[RR”RtMXSymbolInferShapePartialtMXSymbolInferShapeRRZRR~R\R–RŠ(R'tpartialRwRxR»tindptrR„R(RyR¼R½targ_shape_sizetarg_shape_ndimtarg_shape_datatout_shape_sizetout_shape_ndimtout_shape_datataux_shape_sizetaux_shape_ndimtaux_shape_dataRÄt infer_funcRÒt out_shapest aux_shapes((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRÊsr$                     444 cC@s;tjƒ}ttj|jtj|ƒƒƒt|jƒS(s'Gets a debug string of symbol. It contains Symbol output, variables and operators in the computation graph with their inputs, variables and attributes. Returns ------- string Debug string of the symbol. Examples -------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.sin(a) >>> c = 2 * a + b >>> d = mx.sym.FullyConnected(data=c, num_hidden=10) >>> d.debug_str() >>> print d.debug_str() Symbol Outputs: output[0]=fullyconnected0(0) Variable:a -------------------- Op:_mul_scalar, Name=_mulscalar0 Inputs: arg[0]=a(0) version=0 Attrs: scalar=2 -------------------- Op:sin, Name=sin0 Inputs: arg[0]=a(0) version=0 -------------------- Op:elemwise_add, Name=_plus0 Inputs: arg[0]=_mulscalar0(0) arg[1]=sin0(0) Variable:fullyconnected0_weight Variable:fullyconnected0_bias -------------------- Op:FullyConnected, Name=fullyconnected0 Inputs: arg[0]=_plus0(0) arg[1]=fullyconnected0_weight(0) version=0 arg[2]=fullyconnected0_bias(0) version=0 Attrs: num_hidden=10 ( R[R~RRt MXSymbolPrintRZR\RR–(R't debug_str((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRë`s0  cC@sAt|tƒstdƒ‚nttj|jt|ƒƒƒdS(sòSaves symbol to a file. You can also use pickle to do the job if you only work on python. The advantage of `load`/`save` functions is that the file contents are language agnostic. This means the model saved by one language binding can be loaded by a different language binding of `MXNet`. You also get the benefit of being able to directly load/save from cloud storage(S3, HDFS). Parameters ---------- fname : str The name of the file. - "s3://my-bucket/path/my-s3-symbol" - "hdfs://my-bucket/path/my-hdfs-symbol" - "/path-to/my-local-symbol" See Also -------- symbol.load : Used to load symbol from file. sfname need to be stringN(R.R R2RRtMXSymbolSaveToFileRZR(R'tfname((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytsave•scC@s;tjƒ}ttj|jtj|ƒƒƒt|jƒS(s‹Saves symbol to a JSON string. See Also -------- symbol.load_json : Used to load symbol from JSON string. ( R[R~RRtMXSymbolSaveToJSONRZR\RR–(R'Rt((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRp¯s "cC@s]g}g}t|tƒrŽt|ƒt|ƒkrFtd|ƒ‚nx<|D]4}t|tƒsqtdƒ‚n|j|jƒqMW|}n¼t|tƒr>xª|D]“}||krþ||}t|tƒsÞtdƒ‚n|j|jƒ|j|ƒq¤|r!|jdƒ|jdƒq¤td||fƒ‚q¤Wn tdƒ‚t t |ƒ|fS(snHelper function to get NDArray lists handles from various inputs. Parameters ---------- arg_key : str The name of argument, used for error message. args : list of NDArray or dict of str to NDArray Input arguments to the symbols. If type is list of NDArray, the position is in the same order of arg_names. If type is dict of str to NDArray, then it maps the name of arguments to the corresponding NDArray, args_names : list of string List of argument names. allow_missing : boolean Whether missing argument is allowed. When allowed, the missing handle will be set to None(null) Returns ------- handles : list of NDArrayHandle The positional list of NDArrayHandles generated from input. s3Length of %s does not match the number of argumentss6Only accept list of NDArrays or dict of str to NDArrayskey `%s` is missing in `%s`N( R.tlistR|RŒRR2R¹RZtdictR#RR (targ_keyRwRÓt allow_missingt arg_handlest arg_arraystnarrR"((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt_get_ndarray_inputsºs0       twritec0"K@s‡d} tjtjƒƒ} tjtƒƒ} |d k rég} g} xh|jƒD]Z\} } tj| ƒj} | t krR| j t | ƒƒ| j tj t | ƒƒqRqRWtt | ƒƒ} ttj| ƒ} ttj | ƒ} ng}dg}g}x_|jƒD]Q\} } t| tƒr |j t | ƒƒ|j| ƒ|j t |ƒƒq q Wd}tjtjƒƒ}tjtjƒƒ}|d k rÖt|tƒrÃd}t |ƒg}nþt|tƒr!t |ƒdkrótdƒ‚ng|D]}t |ƒ^qú}t |ƒ}n t|tƒrÁt |ƒdkrQtdƒ‚ng}g}x@|jƒD]2\} } |j t | ƒƒ|j t | ƒƒqjWttj|ƒ}t |ƒ}nttj|ƒ}ntdƒ}tjtjƒƒ}tjtj ƒƒ}tjtj ƒƒ}|d k rìg}g}g}x_|jƒD]Q\}}|j t |ƒƒ|j tj |jƒƒ|j tj |jƒƒqLWtt |ƒƒ}ttj|ƒ}ttj |ƒ}ttj |ƒ}ng}|d k r>t|tƒstdƒ‚ng|D]}t |ƒ^q#}n|d krƒtj dƒ}tjtjƒƒ}tjtƒƒ}n t|tƒs¡tdƒ‚ng}g}x=|jƒD]/\} } |j t | ƒƒ|j | jƒqºWttj|ƒ}tj t |ƒƒ}tt|ƒ}tjtjƒƒ} tjtƒƒ}!|d k r_|jntƒ}"tƒ}#tjƒ}$tjtƒƒ}%tjtƒƒ}&tjƒ}'tjtƒƒ}(y%ttj|jtj |jƒtj |jƒ||||t|ƒ||tt |ƒƒttj|ƒtt|ƒtt|ƒ| | | tt |ƒƒttj|ƒtj |ƒ||tj | ƒtj |!ƒtj |$ƒtj |%ƒtj |&ƒtj |'ƒtj |(ƒ|"tj |#ƒƒƒWndt!k rJ})d}*x.|jƒD] \} } |*d| | f7}*q W|*d |)7}*t|*ƒ‚nX|d k r¤xJt"|j#ƒD]6}+t$| |+ƒ} t%t|!|+ƒƒ} | || >> x = mx.sym.Variable('x') >>> y = mx.sym.FullyConnected(x, num_hidden=4) >>> exe = y.simple_bind(mx.cpu(), x=(5,4), grad_req='null') >>> exe.forward() [] >>> exe.outputs[0].asnumpy() array([[ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.], [ 0., 0., 0., 0.]], dtype=float32) >>> exe.arg_arrays [, , ] >>> exe.grad_arrays [, , ] Parameters ---------- ctx : Context The device context the generated executor to run on. grad_req: string {'write', 'add', 'null'}, or list of str or dict of str to str, optional To specify how we should update the gradient to the `args_grad`. - 'write' means every time gradient is written to specified `args_grad` NDArray. - 'add' means every time gradient is added to the specified NDArray. - 'null' means no action is taken, the gradient may not be calculated. type_dict : Dict of str->numpy.dtype Input type dictionary, name->dtype group2ctx : Dict of string to mx.Context The dict mapping the `ctx_group` attribute to the context assignment. shared_arg_names : List of string The argument names whose `NDArray` of shared_exec can be reused for initializing the current executor. shared_exec : Executor The executor whose arg_arrays, arg_arrays, grad_arrays, and aux_arrays can be reused for initializing the current executor. shared_buffer : Dict of string to `NDArray` The dict mapping argument names to the `NDArray` that can be reused for initializing the current executor. This buffer will be checked for reuse if one argument name of the current executor is not found in `shared_arg_names`. kwargs : Dict of str->shape Input shape dictionary, name->shape Returns ------- executor : mxnet.Executor The generated executor is/grad_req in simple_bind cannot be an empty lists/grad_req in simple_bind cannot be an empty dicts6shared_arg_names in simple_bind must be a list or Noneiÿÿÿÿs1shared_buffer in simple_bind must be dict or Nonessimple_bind error. Arguments: s%s: %s s%sN(*R[RR~RR#R§R·R¸R4RR¹RR”R|RR.RØRÙR Rðt RuntimeErrorRñt device_typeidt device_idRŒR RZR R®RRtMXExecutorSimpleBindR\RRŠR–RRRRõt grad_arrayst aux_arrays(0R'tctxtgrad_reqt type_dictt group2ctxtshared_arg_namest shared_exect shared_bufferRxtnum_provided_arg_typestprovided_arg_type_namestprovided_arg_type_dataR¼R½tprovided_arg_shape_datatprovided_arg_shape_idxtprovided_arg_shape_namestprovided_req_type_list_lentprovided_grad_req_typestprovided_grad_req_namestitemtnum_ctx_map_keyst ctx_map_keystctx_map_dev_typestctx_map_dev_idsRƒRtshared_arg_name_listR"tshared_buffer_lentshared_buffer_namestshared_buffer_handlestupdated_shared_buffer_namestupdated_shared_buffer_handlestshared_exec_handlet exe_handlet num_in_argstin_arg_handlestarg_grad_handlestnum_aux_statestaux_state_handlestet error_msgR(RõRýRþtexecutor((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt simple_bindòsC  !      "                2E/   cC@s^t|tƒstdƒ‚n|jƒ}|jd||tƒ\} }|dkrsttdgt |ƒƒ} n|jd||t ƒ\} }|dkr¦g}n|jd||j ƒtƒ\} }t|t ƒr'|t krþtdtt ƒƒ‚ntttt |ƒgt |ƒƒ} n³t|tƒrettg|D]} tt | ƒ^qCƒ} nut|tƒrÚg}xK|D]C}||kr±|jtt ||ƒƒq|jtdƒƒqWtt|ƒ} ng}g}g}|rWxb|jƒD]Q\}}|jt|ƒƒ|jtj|jƒƒ|jtj|jƒƒqÿWntƒ}|dk ru|jntƒ}ttj|jtj|jƒtj|jƒtt |ƒƒttj|ƒttj|ƒttj|ƒtt |ƒƒ| | | tt |ƒƒ| |tj |ƒƒƒt!|||||ƒ}||_"||_#||_$|S(s¸Binds the current symbol to an executor and returns it. We first declare the computation and then bind to the data to run. This function returns an executor which provides method `forward()` method for evaluation and a `outputs()` method to get all the results. Example usage: ---------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.Variable('b') >>> c = a + b >>> ex = c.bind(ctx=mx.cpu(), args={'a' : mx.nd.ones([2,3]), 'b' : mx.nd.ones([2,3])}) >>> ex.forward() [] >>> ex.outputs[0].asnumpy() [[ 2. 2. 2.] [ 2. 2. 2.]] Parameters ---------- ctx : Context The device context the generated executor to run on. args : list of NDArray or dict of str to NDArray Input arguments to the symbol. - If the input type is a list of `NDArray`, the order should be same as the order of `list_arguments()`. - If the input type is a dict of str to `NDArray`, then it maps the name of arguments to the corresponding `NDArray`. - In either case, all the arguments must be provided. args_grad : list of NDArray or dict of str to `NDArray`, optional When specified, `args_grad` provides NDArrays to hold the result of gradient value in backward. - If the input type is a list of `NDArray`, the order should be same as the order of `list_arguments()`. - If the input type is a dict of str to `NDArray`, then it maps the name of arguments to the corresponding NDArray. - When the type is a dict of str to `NDArray`, one only need to provide the dict for required argument gradient. Only the specified argument gradient will be calculated. grad_req : {'write', 'add', 'null'}, or list of str or dict of str to str, optional To specify how we should update the gradient to the `args_grad`. - 'write' means everytime gradient is write to specified `args_grad` `NDArray`. - 'add' means everytime gradient is add to the specified NDArray. - 'null' means no action is taken, the gradient may not be calculated. aux_states : list of `NDArray`, or dict of str to `NDArray`, optional Input auxiliary states to the symbol, only needed when the output of `list_auxiliary_states()` is not empty. - If the input type is a list of `NDArray`, the order should be same as the order of `list_auxiliary_states()`. - If the input type is a dict of str to `NDArray`, then it maps the name of `auxiliary_states` to the corresponding `NDArray`, - In either case, all the auxiliary states need to be provided. group2ctx : Dict of string to mx.Context The dict mapping the `ctx_group` attribute to the context assignment. shared_exec : mx.executor.Executor Executor to share memory with. This is intended for runtime reshaping, variable length sequences, etc. The returned executor shares state with `shared_exec`, and should not be used in parallel with it. Returns ------- executor : Executor The generated executor Notes ----- Auxiliary states are the special states of symbols that do not correspond to an argument, and do not have gradient but are still useful for the specific operations. Common examples of auxiliary states include the `moving_mean` and `moving_variance` states in `BatchNorm`. Most operators do not have auxiliary states and in those cases, this parameter can be safely ignored. One can give up gradient by using a dict in `args_grad` and only specify gradient they interested in. sContext type errorRwt args_gradt aux_statessgrad_req must be in %siN(%R.RR2R±R÷RËR#RR R|RÌR´R RRŒR3RRðRñR¹R§RR[R”RúRûR RZRRtMXExecutorBindEXR~R\RRõRýRþ(R'RÿRwR%RR&RRtlisted_argumentst args_handletargs_grad_handletaux_args_handlet reqs_arrayRt req_arrayR"RRRRƒRRZt shared_handleR#((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytbindÞsrZ     #/       cC@srtƒ}ttjg|D]}t|ƒ^qƒ}ttj|jt t |ƒƒ|tj |ƒƒƒt |ƒS(sÎGets the autodiff of current symbol. This function can only be used if current symbol is a loss function. .. note:: This function is currently not implemented. Parameters ---------- wrt : Array of String keyword arguments of the symbol that the gradients are taken. Returns ------- grad : Symbol A gradient Symbol with returns to be the corresponding gradients. ( R RR[R~RRRt MXSymbolGradRZRR|R\R!(R'twrtRZRƒtc_wrt((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytgradient|s +cK@s.|dkrtj}n|j||ƒjƒS(sEEvaluates a symbol given arguments. The `eval` method combines a call to `bind` (which returns an executor) with a call to `forward` (executor method). For the common use case, where you might repeatedly evaluate with same arguments, eval is slow. In that case, you should call `bind` once and then repeatedly call forward. This function allows simpler syntax for less cumbersome introspection. Example usage: ---------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.Variable('b') >>> c = a + b >>> ex = c.eval(ctx = mx.cpu(), a = mx.nd.ones([2,3]), b = mx.nd.ones([2,3])) >>> ex [] >>> ex[0].asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) Parameters ---------- ctx : Context The device context the generated executor to run on. kwargs : Keyword arguments of type `NDArray` Input arguments to the symbol. All the arguments must be provided. Returns ---------- result : a list of NDArrays corresponding to the values taken by each symbol when evaluated on given args. When called on a single symbol (not a group), the result will be a list with one element. N(R#Rt default_ctxR/tforward(R'RÿRx((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyteval—s$  cC@st|d|ƒS(sáShorthand for mxnet.sym.reshape. Parameters ---------- shape : tuple of int The new shape should not change the array size, namely ``np.prod(new_shape)`` should be equal to ``np.prod(self.shape)``. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. Returns ------- Symbol A reshaped symbol. RÕ(treshape(R'RÕ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR7¿scC@st|jdƒ‚dS(N(Rt wait_to_readR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR8ÒscC@st|jdƒ‚dS(N(RtasnumpyR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR9ÕscC@st|jdƒ‚dS(N(RtasscalarR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR:ØscC@st|jdƒ‚dS(N(RtastypeR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR;ÛscC@st|jdƒ‚dS(N(RtcopyR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR<ÞscC@st|jdƒ‚dS(N(Rt as_in_contextR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR=áscC@st|jdƒ‚dS(N(RtdetachR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR>äscC@st|jdƒ‚dS(N(RtbackwardR#(R'((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR?çsN(KR&t __module__t__doc__t __slots__R)R,R6R7R8R;R<R>RARBRCRFRHRKRMRNRORPRQRTRURVRXRWR`RcRfRiRlRoRqRuRzRvR“tpropertyR"RšRËR¢R¦R©R«R­R±R+R´R¶RÈRÖR×RÊRëRîRpt staticmethodR÷R#R$R/R3R6R7R8R9R:R;R<R=R>R?(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR!CsŽ                   $ 7 /        &  a R 1 D 5  8 ë  (        c K@s´t|tƒstdƒ‚ntƒ}ttjt|ƒtj |ƒƒƒt |ƒ} t j j |ƒ}|d kr|in|}|d k r¡t|ƒ|d>> data = mx.sym.Variable('data', attr={'a': 'b'}) >>> data Parameters ---------- name : str Variable name. attr : Dict of strings Additional attributes to set on the variable. Format {string : string}. shape : tuple The shape of a variable. If specified, this will be used during the shape inference. If one has specified a different shape for this variable using a keyword argument when calling shape inference, this shape information will be ignored. lr_mult : float The learning rate multiplier for input variable. wd_mult : float Weight decay multiplier for input variable. dtype : str or numpy.dtype The dtype for input variable. If not specified, this value will be inferred. init : initializer (mxnet.init.*) Initializer for this variable to (optionally) override the default initializer. kwargs : Additional attribute variables Additional attributes must start and end with double underscores. Returns ------- variable : Symbol A symbol corresponding to an input to the computation graph. s#Expect a string for variable `name`t __shape__t __lr_mult__t __wd_mult__t __dtype__t__init__t__swAttribute name=%s is not supported. Additional attributes must start and end with double underscores, e.g, __yourattr__N(R.R R2R RRtMXSymbolCreateVariableRR[R\R!RtcurrenttgetR#R3RR·R¸R4tdumpsR§t startswithtendswithRŒR©( R"RšRÕtlr_multtwd_multR¸tinitRxRZR—R¼R½((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytvarês4# %     #   cC@sg}x<|D]4}t|tƒs1tdƒ‚n|j|jƒq Wtƒ}ttjt t |ƒƒt t|ƒt j |ƒƒƒt|ƒS(s†Creates a symbol that contains a collection of other symbols, grouped together. Example usage: ---------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.Variable('b') >>> mx.sym.Group([a,b]) Parameters ---------- symbols : list List of symbols to be grouped. Returns ------- sym : Symbol A group symbol. s#Expected a list of symbols as input(R.R!R2R¹RZR RRtMXSymbolCreateGroupRR|RR[R\(tsymbolstihandlestsymRZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyR‰/s   cC@sVt|tƒstdƒ‚ntƒ}ttjt|ƒtj |ƒƒƒt |ƒS(sÎLoads symbol from a JSON file. You can also use pickle to do the job if you only work on python. The advantage of load/save is the file is language agnostic. This means the file saved using save can be loaded by other language binding of mxnet. You also get the benefit being able to directly load/save from cloud storage(S3, HDFS). Parameters ---------- fname : str The name of the file, examples: - `s3://my-bucket/path/my-s3-symbol` - `hdfs://my-bucket/path/my-hdfs-symbol` - `/path-to/my-local-symbol` Returns ------- sym : Symbol The loaded symbol. See Also -------- Symbol.save : Used to save symbol into file. sfname need to be string( R.R R2R RRtMXSymbolCreateFromFileRR[R\R!(RíRZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytloadOs  %cC@sVt|tƒstdƒ‚ntƒ}ttjt|ƒtj |ƒƒƒt |ƒS(sLoads symbol from json string. Parameters ---------- json_str : str A JSON string. Returns ------- sym : Symbol The loaded symbol. See Also -------- Symbol.tojson : Used to save symbol into json string. sfname required to be string( R.R R2R RRRrRR[R\R!(RtRZ((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt load_jsonps  %cC@sèt|tƒr.t|tƒr.tj||ƒSt|tƒr_t|tƒr_tj|d|ƒSt|tƒrt|tƒrtj|d|ƒSt|tƒr¶t|tƒr¶||Stdtt |ƒƒtt |ƒƒfƒ‚dS(s¢Returns element-wise result of base element raised to powers from exp element. Both inputs can be Symbol or scalar number. Broadcasting is not supported. Use `broadcast_pow` instead. Parameters --------- base : Symbol or scalar The base symbol exp : Symbol or scalar The exponent symbol Returns ------- Symbol or scalar The bases in x raised to the exponents in y. Examples -------- >>> mx.sym.pow(2, 3) 8 >>> x = mx.sym.Variable('x') >>> y = mx.sym.Variable('y') >>> z = mx.sym.pow(x, 2) >>> z.eval(x=mx.nd.array([1,2]))[0].asnumpy() array([ 1., 4.], dtype=float32) >>> z = mx.sym.pow(3, y) >>> z.eval(y=mx.nd.array([2,3]))[0].asnumpy() array([ 9., 27.], dtype=float32) >>> z = mx.sym.pow(x, y) >>> z.eval(x=mx.nd.array([3,4]), y=mx.nd.array([2,3]))[0].asnumpy() array([ 9., 64.], dtype=float32) R-stypes (%s, %s) not supportedN( R.R!R/RRRRSt _RPowerScalarR2R3R4(tbasetexp((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytpowŠs"cC@sôt|tƒr.t|tƒr.tj||ƒSt|tƒr_t|tƒr_tj|d|ƒSt|tƒrt|tƒrtj|d|ƒSt|tƒrÂt|tƒrÂ||kr¾|S|Stdtt|ƒƒtt|ƒƒfƒ‚dS(s/Returns element-wise maximum of the input elements. Both inputs can be Symbol or scalar number. Broadcasting is not supported. Parameters --------- left : Symbol or scalar First symbol to be compared. right : Symbol or scalar Second symbol to be compared. Returns ------- Symbol or scalar The element-wise maximum of the input symbols. Examples -------- >>> mx.sym.maximum(2, 3.5) 3.5 >>> x = mx.sym.Variable('x') >>> y = mx.sym.Variable('y') >>> z = mx.sym.maximum(x, 4) >>> z.eval(x=mx.nd.array([3,5,2,10]))[0].asnumpy() array([ 4., 5., 4., 10.], dtype=float32) >>> z = mx.sym.maximum(x, y) >>> z.eval(x=mx.nd.array([3,4]), y=mx.nd.array([10,2]))[0].asnumpy() array([ 10., 4.], dtype=float32) R-stypes (%s, %s) not supportedN( R.R!R/t_MaximumRt_MaximumScalarR2R3R4(tlefttright((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytmaximumºscC@sôt|tƒr.t|tƒr.tj||ƒSt|tƒr_t|tƒr_tj|d|ƒSt|tƒrt|tƒrtj|d|ƒSt|tƒrÂt|tƒrÂ||kr¾|S|Stdtt|ƒƒtt|ƒƒfƒ‚dS(s'Returns element-wise minimum of the input elements. Both inputs can be Symbol or scalar number. Broadcasting is not supported. Parameters --------- left : Symbol or scalar First symbol to be compared. right : Symbol or scalar Second symbol to be compared. Returns ------- Symbol or scalar The element-wise minimum of the input symbols. Examples -------- >>> mx.sym.minimum(2, 3.5) 2 >>> x = mx.sym.Variable('x') >>> y = mx.sym.Variable('y') >>> z = mx.sym.minimum(x, 4) >>> z.eval(x=mx.nd.array([3,5,2,10]))[0].asnumpy() array([ 3., 4., 2., 4.], dtype=float32) >>> z = mx.sym.minimum(x, y) >>> z.eval(x=mx.nd.array([3,4]), y=mx.nd.array([10,2]))[0].asnumpy() array([ 3., 2.], dtype=float32) R-stypes (%s, %s) not supportedN( R.R!R/t_MinimumRt_MinimumScalarR2R3R4(RbRc((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytminimumæscC@sðt|tƒr.t|tƒr.tj||ƒSt|tƒr_t|tƒr_tj|d|ƒSt|tƒrt|tƒrtj|d|ƒSt|tƒr¾t|tƒr¾tj||ƒStdt t |ƒƒt t |ƒƒfƒ‚dS(s{Given the "legs" of a right triangle, returns its hypotenuse. Equivalent to :math:`\sqrt(left^2 + right^2)`, element-wise. Both inputs can be Symbol or scalar number. Broadcasting is not supported. Parameters --------- left : Symbol or scalar First leg of the triangle(s). right : Symbol or scalar Second leg of the triangle(s). Returns ------- Symbol or scalar The hypotenuse of the triangle(s) Examples -------- >>> mx.sym.hypot(3, 4) 5.0 >>> x = mx.sym.Variable('x') >>> y = mx.sym.Variable('y') >>> z = mx.sym.hypot(x, 4) >>> z.eval(x=mx.nd.array([3,5,2]))[0].asnumpy() array([ 5., 6.40312433, 4.47213602], dtype=float32) >>> z = mx.sym.hypot(x, y) >>> z.eval(x=mx.nd.array([3,4]), y=mx.nd.array([10,2]))[0].asnumpy() array([ 10.44030666, 4.47213602], dtype=float32) R-stypes (%s, %s) not supportedN( R.R!R/t_HypotRt _HypotScalarR·thypotR2R3R4(RbRc((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyRjscK@s1|dkrtj}ntjd|d||S(s^Returns a new symbol of given shape and type, filled with zeros. Parameters ---------- shape : int or sequence of ints Shape of the new array. dtype : str or numpy.dtype, optional The value type of the inner value, default to ``np.float32``. Returns ------- out : Symbol The created Symbol. RÕR¸N(R#R·tfloat32R/t_zeros(RÕR¸Rx((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytzeros=s  cK@s1|dkrtj}ntjd|d||S(s\Returns a new symbol of given shape and type, filled with ones. Parameters ---------- shape : int or sequence of ints Shape of the new array. dtype : str or numpy.dtype, optional The value type of the inner value, default to ``np.float32``. Returns ------- out : Symbol The created Symbol RÕR¸N(R#R·RkR/t_ones(RÕR¸Rx((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytonesQs  cK@s=|dkrtj}ntjtd|d||d|ƒS(s‘Returns a new array of given shape and type, filled with the given value `val`. Parameters ---------- shape : int or sequence of ints Shape of the new array. val : scalar Fill value. dtype : str or numpy.dtype, optional The value type of the inner value, default to ``np.float32``. Returns ------- out : Symbol The created Symbol RÕR¸R-N(R#R·RkR/R@Ro(RÕRR¸Rx((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytfulles  gð?c C@sF|dkrtj}ntjd|d|d|d|d|d|ƒS(s¬Returns evenly spaced values within a given interval. Parameters ---------- start : number Start of interval. The interval includes this value. The default start value is 0. stop : number, optional End of interval. The interval does not include this value. step : number, optional Spacing between values. repeat : int, optional "The repeating time of all elements. E.g repeat=3, the element a will be repeated three times --> a, a, a. dtype : str or numpy.dtype, optional The value type of the inner value, default to ``np.float32``. Returns ------- out : Symbol The created Symbol R†R‡RˆtrepeatR"R¸N(R#R·RkR/t_arange(R†R‡RˆRqR"R¸((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytarange{s  !c B@sÙejƒ}ejƒ}eƒ}ejejƒƒ}ejejƒƒ}ejejƒƒ}ejƒ}ejƒ} eej|ej|ƒej|ƒej|ƒej|ƒej|ƒej|ƒej|ƒej| ƒƒ ƒe|j ƒ} ge | ƒD]} e || ƒ^q}ge | ƒD]} e || ƒ^q0}|} e |j ƒ}| j dk re | j ƒnd} e | e |j ƒ||ge | ƒD]} e || ƒ^qª|| ƒ} d}d}g}g}g}g}xèe | ƒD]Ú} || || }}|dkrA|}|jd|ƒq|jdƒs_|jdƒr¼| srtdƒ‚|jdƒr›|jd|ƒ|}qÚ|jd |ƒ|j|ƒq|jd|ƒ|j|ƒqW|jd ƒ|jd ƒ|jd ƒ|jd ƒ||}g}|rÌ|jd| |fƒ|jdj|ƒƒ|dk r~|jd|||fƒn|jd| jƒƒ|rµ|jd||fƒn|jd|j ƒnË|jd| dj|ƒfƒ|jdƒx'|D]}|jdjd|ƒƒqWx(|D] }|jd|||fƒq*W|dk rw|jd|||fƒn|jd| jƒ|j fƒi}dj|ƒd|U|| }| |_| |_d|_|S(s=Create an atomic symbol function by handle and function name.tR¸s%s=_NullRR!sROp can only have one argument with variable size and it must be the last argument.s[]s*%ss%s=Nones name=Nones attr=Nonesout=Nones**kwargss def %s(*%s, **kwargs):sÊ sym_args = [] for i in {}: assert isinstance(i, SymbolBase), \ "Positional arguments must be Symbol instances, " \ "but got %s"%str(i) sym_args.append(i)sN if '%s' in kwargs: kwargs['%s'] = _numpy.dtype(kwargs['%s']).names¢ attr = kwargs.pop('attr', None) kwargs.update(AttrScope.current.get(attr)) name = kwargs.pop('name', None) name = NameManager.current.get(name, '%s') _ = kwargs.pop('out', None) keys = [] vals = [] sym_kwargs = dict() for k, v in kwargs.items(): if isinstance(v, SymbolBase): sym_kwargs[k] = v else: keys.append(k) vals.append(v)sj if '%s' not in kwargs: keys.append('%s') vals.append(len(sym_args) + len(sym_kwargs))sG return _symbol_creator(%d, sym_args, sym_kwargs, keys, vals, name)so def %s(%s): kwargs.update(AttrScope.current.get(attr)) sym_kwargs = dict() keys = [] vals = []s, s¨ for k, v in kwargs.items(): if isinstance(v, SymbolBase): sym_kwargs[k] = v else: keys.append(k) vals.append(v)sÁ if {name} is not None: assert isinstance({name}, SymbolBase), \ "Argument {name} must be Symbol instances, but got %s"%str({name}) sym_kwargs['{name}'] = {name}R"sJ if %s is not _Null: keys.append('%s') vals.append(%s)s] if %s is not _Null: keys.append('%s') vals.append(_numpy.dtype(%s).name)sr name = NameManager.current.get(name, '%s') return _symbol_creator(%d, None, sym_kwargs, keys, vals, name)s mxnet.symbolN(R[R~RRRRtMXSymbolGetAtomicSymbolInfoR\RR–RŠRR#RR¹ROtAssertionErrorRPtformattlowerR$R&RAR@(RZR"t real_nametdescR‚RÓRÅt arg_descstkey_var_num_argstret_typetnargR(t func_nametdoc_strt dtype_nametarr_namet ndsignaturet signaturet ndarg_namest kwarg_namestatypetcodetlocaltsymbol_function((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt_make_atomic_symbol_function—s           ))$ &                  c C@s‹t|ƒtjtjƒƒ}tjƒ}ttjtj|ƒtj|ƒƒƒg}x.t |j ƒD]}|j t ||ƒƒqiWt jd|}t jd|}t jd|}xÇ|D]¿} tƒ} ttjt| ƒtj| ƒƒƒt| | ƒ} | jjdƒrH| jd| _d| _t|| j| ƒqÄ| jjdƒrpt|| j| ƒqÄt|| j| ƒqÄWdS( s?List and add all the atomic symbol functions to current module.s %s.symbols%s._symbol_internals%s.contrib.symbolt _contrib_i smxnet.contrib.symbolR]N(RR[RR~R®RRtMXListAllOpNamesR\RŠR–R¹Rt_systmodulesR t NNGetOpHandleRR‹R&ROR@tsetattr( t symbol_classtroot_namespacetplistR top_namesR(t module_objtmodule_internaltmodule_contribR"thdltfunction((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pyt_init_symbol_module0 s,    % tmxnet(RRAt __future__Rt_abst __builtin__RR…t ImportErrortbuiltinsR[RÏtnumbersRtost_ostsysRŽtnumpyR·R]RRRRRRR R R R R RRRRtcontextRtndarrayRRRRR"RR#RRtRR/t attributeRt symbol_docRRtenvironRMRÌt_ctypes.symbolRRRt version_infot _cy3.symbolt _cy2.symbolRËR!R#RTtVariableR‰RZR[R_RdRgRjRmRoRpRsR‹R›(((s,build/bdist.linux-armv7l/egg/mxnet/symbol.pytsv      ("""! !ÿÿÿÿÿÿ­B !  0 , , +    ™