ó šÄïYc@`s dZddlmZddlmZyddlmZWn!ek r]ddlmZnXddl Z ddl Z ddl Z ddl ZddlZddlZddlmZmZmZmZddlmZmZmZmZmZdd lmZmZmZmZdd lm Z dd l!m"Z"dd l#m$Z%dd l&m'Z'yÐe(e j)j*de+ƒƒdkr¥ddl,m-Z-m.Z.ddl,m/Z/m0Z0n|ej1ddfkrïddl2m-Z-m.Z.m0Z0ddl2m/Z/m0Z0n2ddl3m-Z-m.Z.m0Z0ddl3m/Z/m0Z0Wnsek r—e(e j)j*de4ƒƒdkrbedƒ‚nddl,m-Z-m.Z.m0Z0ddl,m/Z/m0Z0nXide56dej66dej76dej86dej96dej:6dej;6dej<6Z=ie5d6ej6d6ej7d6ej8d6ej9d6ej:d6ej;d6ej<d6Z>idd6dd6dd6Z?d„Z@ed„ZAd„ZBd e-fd!„ƒYZCd"„ZDe5ed#„ZEe5ed$„ZFe5ed%„ZGe5ee5d&„ZHe5e5d'„ZId(„ZJe5d)de5ed*„ZKe5d+„ZLd,„ZMd-„ZNd.„ZOd/„ZPd0„ZQd1„ZRd2„ZSd3„ZTd4„ZUd5„ZVd6„ZWd7„ZXd8„ZYd9„ZZd:„Z[d;„Z\d<„Z]d=„Z^de+d>„Z_ddddfe5dde5d?„Z`d@„ZadA„ZbebeCdBƒdS(CsNDArray API of MXNet.i(tabsolute_import(tdivision(tsliceNi(t_LIBt string_typest numeric_typest integer_types(tc_arraytpy_strtc_strt mx_real_tt_Null(tmx_uintt NDArrayHandlet check_calltOpHandle(t ctypes2buffer(tContext(t_ndarray_internal(t _build_doctMXNET_ENABLE_CYTHON(t NDArrayBaset_set_ndarray_class(tCachedOpt_imperative_invokei(RRRtMXNET_ENFORCE_CYTHONs9Cython Module cannot be loaded but MXNET_ENFORCE_CYTHON=1iÿÿÿÿiiiitnulltwritetaddcC`s)tƒ}ttjtj|ƒƒƒ|S(sšReturns a new empty handle. Empty handle can be used to hold a result. Returns ------- handle A new empty `NDArray` handle. (R RRtMXNDArrayCreateNonetctypestbyref(thdl((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt_new_empty_handle`s c C`s–tƒ}ttjtt|ƒtt|ƒƒtj|j ƒtj|j ƒtjt |ƒƒtjt t t j|ƒjƒƒtj|ƒƒƒ|S(s´Return a new handle with specified shape and context. Empty handle is only used to hold results. Returns ------- handle A new empty `NDArray` handle. (R RRtMXNDArrayCreateExRR tlenRtc_intt device_typeidt device_idtintt_DTYPE_NP_TO_MXtnptdtypettypeR(tshapetctxt delay_allocR*R ((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt_new_alloc_handlens   "cC`sttjƒƒdS(shWait for all async operations to finish in MXNet. This function is used for benchmarking only. N(RRtMXNDArrayWaitAll(((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytwaitallƒstNDArraycB`sxeZdZgZdZd„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!e!Z"d„Z#d „Z$d!„Z%d"„Z&d#„Z'd$„Z(d%„Z)d&„Z*d'„Z+d(„Z,d)„Z-d*„Z.e/d+„ƒZ0e/d,„ƒZ1e/d-„ƒZ2e/d.„ƒZ3e/d/„ƒZ4e/d0„ƒZ5e/d1„ƒZ6e6j7d2„ƒZ6d3„Z8d4„Z9d5„Z:d6„Z;d7„Z<d8„Z=d9d:„Z>e/d;„ƒZ?d<„Z@d>eBeCd=„ZDRS(?s]An array object representing a multidimensional, homogeneous array of fixed-size items. g@@cC`sRdjg|jD]}d|^qƒ}dt|jƒƒ|jj||jfS(s-Returns a string representation of the array.txs%ds %s <%s %s @%s>(tjoinR,tstrtasnumpyt __class__t__name__tcontext(tselfR3t shape_info((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__repr__“s) cC`s t||ƒS(s)x.__add__(y) <=> x+y <=> mx.nd.add(x, y) (R(R:tother((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__add__šscC`s…|jstdƒ‚nt|tƒr:t||d|ƒSt|tƒretj|t|ƒd|ƒSt dt t |ƒƒƒ‚dS(sx.__iadd__(y) <=> x+=y s#trying to add to a readonly NDArraytoutstype %s not supportedN( twritablet ValueErrort isinstanceR2t broadcast_addRt _internalt _plus_scalartfloatt TypeErrorR5R+(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__iadd__žs cC`s |j|ƒS(N(R>(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__radd__©scC`s t||ƒS(s.x.__sub__(y) <=> x-y <=> mx.nd.subtract(x, y) (tsubtract(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__sub__¬scC`s…|jstdƒ‚nt|tƒr:t||d|ƒSt|tƒretj|t|ƒd|ƒSt dt t |ƒƒƒ‚dS(sx.__isub__(y) <=> x-=y s*trying to subtract from a readonly NDArrayR?stype %s not supportedN( R@RARBR2t broadcast_subRRDt _minus_scalarRFRGR5R+(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__isub__°s cC`s t||ƒS(s/x.__rsub__(y) <=> y-x <=> mx.nd.subtract(y, x) (RJ(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__rsub__»scC`s t||ƒS(s.x.__mul__(y) <=> x*y <=> mx.nd.multiply(x, y) (tmultiply(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__mul__¿scC`stj|dƒS(sx.__neg__(y) <=> -x gð¿(RDt _mul_scalar(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__neg__ÃscC`s…|jstdƒ‚nt|tƒr:t||d|ƒSt|tƒretj|t|ƒd|ƒSt dt t |ƒƒƒ‚dS(sx.__imul__(y) <=> x*=y s(trying to multiply to a readonly NDArrayR?stype %s not supportedN( R@RARBR2t broadcast_mulRRDRRRFRGR5R+(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__imul__Çs cC`s |j|ƒS(N(RQ(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__rmul__ÒscC`s t||ƒS(s,x.__div__(y) <=> x/y <=> mx.nd.divide(x, y) (tdivide(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__div__ÕscC`s t||ƒS(s-x.__rdiv__(y) <=> y/x <=> mx.nd.divide(y, x) (RW(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__rdiv__ÙscC`s…|jstdƒ‚nt|tƒr:t||d|ƒSt|tƒretj|t|ƒd|ƒSt dt t |ƒƒƒ‚dS(sx.__rdiv__(y) <=> x/=y s(trying to divide from a readonly NDArrayR?stype %s not supportedN( R@RARBR2t broadcast_divRRDt _div_scalarRFRGR5R+(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__idiv__Ýs cC`s t||ƒS(N(RW(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt __truediv__èscC`s t||ƒS(N(RW(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt __rtruediv__ëscC`s |j|ƒS(N(R\(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt __itruediv__îscC`s t||ƒS(s,x.__mod__(y) <=> x%y <=> mx.nd.modulo(x, y) (tmodulo(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__mod__ñscC`s t||ƒS(s-x.__rmod__(y) <=> y%x <=> mx.nd.modulo(y, x) (R`(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__rmod__õscC`s…|jstdƒ‚nt|tƒr:t||d|ƒSt|tƒretj|t|ƒd|ƒSt dt t |ƒƒƒ‚dS(sx.__rmod__(y) <=> x%=y s-trying to take modulo from a readonly NDArrayR?stype %s not supportedN( R@RARBR2t broadcast_modRRDt _mod_scalarRFRGR5R+(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__imod__ùs cC`s t||ƒS(s+x.__pow__(y) <=> x**y <=> mx.nd.power(x,y) (tpower(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__pow__scC`s t||ƒS(s+x.__pow__(y) <=> y**x <=> mx.nd.power(y,x) (Rf(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__rpow__scC`s t||ƒS(s+x.__eq__(y) <=> x==y <=> mx.nd.equal(x, y) (tequal(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__eq__ scC`s t||ƒS(s/x.__ne__(y) <=> x!=y <=> mx.nd.not_equal(x, y) (t not_equal(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__ne__scC`s t||ƒS(s,x.__gt__(y) <=> x>y <=> mx.nd.greater(x, y) (tgreater(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__gt__scC`s t||ƒS(s3x.__ge__(y) <=> x>=y <=> mx.nd.greater_equal(x, y) (t greater_equal(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__ge__scC`s t||ƒS(s+x.__lt__(y) <=> x mx.nd.lesser(x, y) (tlesser(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__lt__scC`s t||ƒS(s0x.__le__(y) <=> x<=y <=> mx.nd.less_equal(x, y) (t lesser_equal(R:R=((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__le__ scC`stdƒ‚dS(Ns[The truth value of an NDArray is ambiguous. Please convert to number with asscalar() first.(RA(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__bool__$scC`s |jdS(s'Number of element along the first axis.i(R,(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt__len__*scC`sŽ|j}idd6}|dk rŠtjƒ}tjtjƒƒ}ttj|jtj |ƒtj |ƒƒƒt ||j ƒ|dx.__setitem__(i, y) <=> x[i]=y Set self[key] to value. Parameters ---------- key : int, slice or tuple The indexing key. value : scalar, NDArray or numpy.ndarray The value to set. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> x[:] = 1 >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> x[:,1:2] = 2 >>> x.asnumpy() array([[ 1., 2., 1.], [ 1., 2., 1.]], dtype=float32) >>> x[1:2,1:] = 3 >>> x.asnumpy() array([[ 1., 2., 1.], [ 1., 3., 3.]], dtype=float32) >>> x[1:,0:2] = mx.nd.zeros((1,2)) >>> x.asnumpy() array([[ 1., 2., 1.], [ 0., 0., 3.]], dtype=float32) >>> x[1,2] = 4 >>> x.asnumpy() array([[ 1., 2., 1.], [ 0., 0., 4.]], dtype=float32) s!Cannot assign to readonly NDArrayNs.NDArray only supports slicing with step size 1R?s6NDArray does not support assignment with %s of type %ss5Indexing dimensions exceed array dimensions, %d vs %diis/NDArray only supports slicing with step size 1.s8NDArray does not support slicing with key %s of type %s.tbegintendtscalarR-R*(%R@RARBRt_attpy_slicetstepRxtstarttstopt_sliceR2RwtcopytoRRDt _set_valueRFR)tndarraytgenerict_sync_copyfromRGR5R+ttupleR,R#tAssertionErrort enumeratetappendt as_in_contextR9t _slice_assignt_crop_assign_scalartarrayR*( R:tkeyR}t sliced_arrtmy_shapet_RˆR3R‰texpandtitslice_i((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt __setitem__Gs~( %   &  %c C`st|jƒ}|r÷t|ƒt|ƒkr÷t|ƒt|ƒt|ƒkrÄgt||ƒD]\}}||^q_}x!t|ƒD]} |j| ƒqˆWtdt|ƒt|ƒfƒ‚nx|D]} |j| dƒqËW|j |ƒ}nt j ||d|d|d|ƒdS(NsBCannot assign NDArray with shape %s to NDArray slice with shape %siR?RˆR‰( tlistR,R#tziptreversedtpopRAR5tinserttreshapeRDt _crop_assign( R:R}RˆR‰R¢tvshapetetbtsshapeR£((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR›·s", cC`s¯t|tƒrU||jddkrHtdj||jdƒƒ‚n|j|ƒSt|tƒr½|jdk r‚t dƒ‚n|j dk s |j dk r¶|j |j |j ƒS|Snît|t ƒrƒ|j}g}g}g}t|ƒt|ƒks!tdt|ƒt|ƒfƒ‚d}x t|ƒD]û\}}t|tƒrp|j|ƒ|j|dƒq4t|tƒr|jdk rt dƒ‚n|j|j dkr¸dn|j ƒ|j|j dkrá||n|j ƒ|j||||ƒq4t dt|ƒtt|ƒƒfƒ‚q4W|j||dƒt|ƒdkrj|jdƒnt|||ƒj|ƒSt dt|ƒtt|ƒƒfƒ‚dS( sEx.__getitem__(i) <=> x[i] Returns a sliced view of this array. Parameters ---------- key : int or slice Indexing key. Examples -------- >>> x = mx.nd.arange(0,6).reshape((2,3)) >>> x.asnumpy() array([[ 0., 1., 2.], [ 3., 4., 5.]], dtype=float32) >>> x[1].asnumpy() array([ 3., 4., 5.], dtype=float32) >>> y = x[0:1] >>> y[:] = 2 >>> x.asnumpy() array([[ 2., 2., 2.], [ 3., 4., 5.]], dtype=float32) iis1index {} is out of bounds for axis 0 with size {}s/NDArray only supports slicing with step size 1.s5Slicing dimensions exceeds array dimensions, %d vs %diÿÿÿÿs8NDArray does not support slicing with key %s of type %s.N(RBRR,t IndexErrortformatR‹RŒRRxRARŽRRR–R#R—R˜R™R5R+textendRR«(R:RžR,toshapeRˆR‰R£R¤((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt __getitem__ÇsR   %)&cC`sët|tjƒs[ytj|d|jƒ}Wq[tddtttƒƒƒ‚q[Xntj|d|jƒ}|j |j kr°t dt|j ƒt|j ƒfƒ‚nt t j |j|jjtjƒtj|jƒƒƒdS(sPerforms a synchronized copy from the `source_array` to the current array. This is called through ``x[:] = source_array``, where the `source_array` is a `numpy.ndarray` or array-like object. This function blocks until all the pending read/write operations with respect to the current `NDArray` are finished and carry out the copy operation to the current NDArray. Parameters ---------- source_array : array_like The data source we would like to copy from. Example ------- >>> a = mx.nd.array([1, 2]) >>> a.asnumpy() array([ 1., 2.], dtype=float32) >>> a[:] = np.array([3, 4]) >> a.asnumpy() array([ 3., 4.], dtype=float32) R*s&array must consist of array-like data,stype %s is not supporteds)Shape inconsistent: expected %s vs got %sN(RBR)R“RR*RGR5R+tascontiguousarrayR,RARRtMXNDArraySyncCopyFromCPURwRtdata_astc_void_pRytsize(R:t source_array((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR• s!% cC`sŠtƒ}|rt|ƒn tdƒ}|r9t|ƒnt|jdƒ}ttj|j||tj|ƒƒƒt d|d|j ƒS(sÆReturns a sliced NDArray that shares memory with the current one. This is called through ``x[start:stop]``. Parameters ---------- start : int Starting inclusive index of slice in the first dim. stop : int Finishing exclusive index of slice in the first dim. Returns ------- `NDArray` sharing the memory with the current one sliced from start to stop in the first dim. Examples: >>> a = mx.nd.array([[1,2], [3, 4], [5, 6], [7, 8]]) >>> a[1:2].asnumpy() array([[ 3., 4.]], dtype=float32) >>> a[1:1].asnumpy() array([], shape=(0, 2), dtype=float32) iRwR@( R R R,RRtMXNDArraySliceRwRRR2R@(R:RŽRRw((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR2s  % cC`sPtƒ}t|ƒ}ttj|j|tj|ƒƒƒtd|d|j ƒS(svReturns a view of the array sliced at `idx` in the first dim. This is called through ``x[idx]``. Parameters ---------- idx : int index for slicing the `NDArray` in the first dim. Returns ------- NDArray `NDArray` sharing the memory with the current one sliced at `idx` in the first dim. Examples -------- >>> a = mx.nd.array([[1,2], [3, 4]]) >>> a[1].asnumpy() array([ 3., 4.], dtype=float32) >>> b = mx.nd.array([1, 2, 3, 4]) >>> b[0].asnumpy() array([ 1.], dtype=float32) RwR@( R R RRt MXNDArrayAtRwRRR2R@(R:tidxRw((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR‹Ps    cC`sYtƒ}ttj|jt|ƒttj|ƒtj |ƒƒƒt d|d|j ƒS(s>Returns a **view** of this array with a new shape without altering any data. 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 dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. 0 Dimensions in shape will be copied from original shape, i.e. if x.shape == (3, 4, 5), x.reshape((0, 20)).shape will be (3, 20). Returns ------- NDArray An array with desired shape that shares data with this array. Examples -------- >>> x = mx.nd.arange(0,6).reshape((2,3)) >>> x.asnumpy() array([[ 0., 1., 2.], [ 3., 4., 5.]], dtype=float32) >>> y = x.reshape((3,2)) >>> y.asnumpy() array([[ 0., 1.], [ 2., 3.], [ 4., 5.]], dtype=float32) >>> y = x.reshape((3,-1)) >>> y.asnumpy() array([[ 0., 1.], [ 2., 3.], [ 4., 5.]], dtype=float32) >>> y[:] = -1 >>> x.asnumpy() array([[-1., -1., -1.], [-1., -1., -1.]], dtype=float32) RwR@( R RRtMXNDArrayReshapeRwR#RRR$RR2R@(R:R,Rw((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR«ms *  cC`sô|j}dj||ƒ}t|ƒt|ƒkrBt|ƒ‚ndt|ƒt|ƒ|}tj|ƒ}tj|tj|ƒkƒ}||dkjƒr²t|ƒ‚n||jkrÚt|j |ƒd|ƒSt|dt |ƒƒSdS(sKBroadcasts the input array to a new shape. Broadcasting is only allowed on axes with size 1. The new shape cannot change the number of dimensions. For example, you could broadcast from shape (2, 1) to (2, 3), but not from shape (2, 3) to (2, 3, 3). Parameters ---------- shape : tuple of int The shape of the desired array. Returns ------- NDArray A NDArray with the desired shape that is not sharing data with this array, even if the new shape is the same as ``self.shape``. Examples -------- >>> x = mx.nd.arange(0,3).reshape((1,3,1)) >>> x.asnumpy() array([[[ 0.], [ 1.], [ 2.]]], dtype=float32) >>> y = x.broadcast_to((2,3,3)) >>> y.asnumpy() array([[[ 0., 0., 0.], [ 1., 1., 1.], [ 2., 2., 2.]], [[ 0., 0., 0.], [ 1., 1., 1.], [ 2., 2., 2.]]], dtype=float32) sloperands could not be broadcast together with remapped shapes[original->remapped]: {} and requested shape {}iR,N(i( R,R²R#RAR)Rtnonzerotanyt broadcast_toR«R–(R:R,t cur_shapeterr_strt cur_shape_arrtbroadcasting_axes((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR¡s$  cC`sttj|jƒƒdS(sKWaits until all previous write operations on the current array are finished. This method guarantees that all previous write operations that pushed into the backend engine for execution are actually finished. Examples -------- >>> import time >>> tic = time.time() >>> a = mx.nd.ones((1000,1000)) >>> b = mx.nd.dot(a, a) >>> print(time.time() - tic) # doctest: +SKIP 0.003854036331176758 >>> b.wait_to_read() >>> print(time.time() - tic) # doctest: +SKIP 0.0893700122833252 N(RRtMXNDArrayWaitToReadRw(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt wait_to_readÕscC`s t|jƒS(sìReturns the number of dimensions of this array Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.ndim 1 >>> x = mx.nd.array([[1, 2], [3, 4]]) >>> x.ndim 2 (R#R,(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytndimês cC`sZtƒ}tjtƒƒ}ttj|jtj|ƒtj|ƒƒƒt||j ƒS(sâTuple of array dimensions. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.shape (4L,) >>> y = mx.nd.zeros((2, 3, 4)) >>> y.shape (2L, 3L, 4L) ( R RRzRRtMXNDArrayGetShapeRwRR–R}(R:RÉtpdata((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR,ùs  %cC`s(d}x|jD]}||9}qW|S(sNumber of elements in the array. Equivalent to the product of the array's dimensions. Examples -------- >>> import numpy as np >>> x = mx.nd.zeros((3, 5, 2)) >>> x.size 30 >>> np.prod(x.shape) 30 i(R,(R:RºR£((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRº scC`s`tjƒ}tjƒ}ttj|jtj|ƒtj|ƒƒƒttj|j |j ƒS(s.Device context of the array. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.context cpu(0) >>> type(x.context) >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> y.context gpu(0) ( RR$RRtMXNDArrayGetContextRwRRt devtype2strR}(R:t dev_typeidtdev_id((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR9 s    %cC`s9tjƒ}ttj|jtj|ƒƒƒt|jS(sbData-type of the array's elements. Returns ------- numpy.dtype This NDArray's data type. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> x.dtype >>> y = mx.nd.zeros((2,3), dtype='int32') >>> y.dtype ( RR$RRtMXNDArrayGetDTypeRwRt_DTYPE_MX_TO_NPR}(R:tmx_dtype((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR*5s  cC`s#t|jƒdkr|St|ƒS(sbReturns a copy of the array with axes transposed. Equivalent to ``mx.nd.transpose(self)`` except that self is returned if ``self.ndim < 2``. Unlike ``numpy.ndarray.T``, this function returns a copy rather than a view of the array unless ``self.ndim < 2``. Examples -------- >>> x = mx.nd.arange(0,6).reshape((2,3)) >>> x.asnumpy() array([[ 0., 1., 2.], [ 3., 4., 5.]], dtype=float32) >>> x.T.asnumpy() array([[ 0., 3.], [ 1., 4.], [ 2., 5.]], dtype=float32) i(R#R,t transpose(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytTLscC`s5tjƒ}ttj|jtj|ƒƒƒ|jS(s5Whether this array's corresponding gradient array (registered via `autograd.mark_variables`) has been updated by `autograd.backward` since last reset. `_fresh_grad` need to be manually set to False after consuming gradient (usually after updating this array). (RR$RRtMXNDArrayGetGradStateRwRR}(R:R?((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt _fresh_gradhs "cC`s&ttj|jtj|ƒƒƒdS(N(RRtMXNDArraySetGradStateRwRR$(R:R„((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRÖvscC`sVtj|jd|jƒ}ttj|j|jj tj ƒtj |j ƒƒƒ|S(sËReturns a ``numpy.ndarray`` object with value copied from this array. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.asnumpy() >>> type(y) >>> y array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> z = mx.nd.ones((2,3), dtype='int32') >>> z.asnumpy() array([[1, 1, 1], [1, 1, 1]], dtype=int32) R*( R)temptyR,R*RRtMXNDArraySyncCopyToCPURwRR¸R¹RyRº(R:tdata((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR6zs  cC`s,|jdkrtdƒ‚n|jƒdS(sTReturns a scalar whose value is copied from this array. This function is equivalent to ``self.asnumpy()[0]``. This NDArray must have shape (1,). Examples -------- >>> x = mx.nd.ones((1,), dtype='int32') >>> x.asscalar() 1 >>> type(x.asscalar()) is!The current array is not a scalari(i(R,RAR6(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytasscalar’s cC`s/t|jd|jd|ƒ}|j|ƒ|S(sgReturns a copy of the array after casting to a specified type. Parameters ---------- dtype : numpy.dtype or str The type of the returned array. Examples -------- >>> x = mx.nd.zeros((2,3), dtype='float32') >>> y = x.astype('int32') >>> y.dtype R-R*(RØR,R9R‘(R:R*tres((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytastype£s cC`s«t|tƒrH|j|jkr5tjdtƒdStj|d|ƒSt|tƒr‹tt |j |t |j ƒƒ}tj|d|ƒSt dtt|ƒƒƒ‚dS(sCopies the value of this array to another array. If ``other`` is a ``NDArray`` object, then ``other.shape`` and ``self.shape`` should be the same. This function copies the value from ``self`` to ``other``. If ``other`` is a context, a new ``NDArray`` will be first created on the target context, and the value of ``self`` is copied. Parameters ---------- other : NDArray or Context The destination array or context. Returns ------- NDArray The copied array. If ``other`` is an ``NDArray``, then the return value and ``other`` will point to the same ``NDArray``. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> z = x.copyto(y) >>> z is y True >>> y.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.copyto(mx.gpu(0)) s-You are attempting to copy an array to itselfNR?scopyto does not support type (RBR2RwtwarningstwarntRuntimeWarningRDt_copytoRR/R,tTrueR*RGR5R+(R:R=thret((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR‘¶s#!cC`s|j|jƒS(sXMakes a copy of this ``NDArray``, keeping the same context. Returns ------- NDArray The copied array Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.copy() >>> y.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) (R‘R9(R:((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytcopyäscC`s |j|kr|S|j|ƒS(s\Returns an array on the target device with the same value as this array. If the target context is the same as ``self.context``, then ``self`` is returned. Otherwise, a copy is made. Parameters ---------- context : Context The target context. Returns ------- NDArray The target array. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.as_in_context(mx.cpu()) >>> y is x True >>> z = x.as_in_context(mx.gpu(0)) >>> z is x False (R9R‘(R:R9((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRšösRcC`s]t|ƒ}t|}ttjdtj|jƒtjt|ƒƒtj|jƒƒƒdS(sÏAttach a gradient buffer to this NDArray, so that `backward` can compute gradient with respect to it. Parameters ---------- grad_req : {'write', 'add', 'null'} How gradient will be accumulated. - 'write': gradient will be overwritten on every backward. - 'add': gradient will be added to existing value on every backward. - 'null': do not compute gradient for this NDArray. iN( t zeros_liket _GRAD_REQ_MAPRRtMXAutogradMarkVariablesRtpointerRwR (R:tgrad_reqtgrad((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt attach_grads   cC`sHtƒ}ttj|jtj|ƒƒƒ|jdkr>dSt |ƒS(s1Returns gradient buffer attached to this NDArray.N( R RRtMXNDArrayGetGradRwRRR}RxR2(R:R ((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRê(s  "cC`s5tƒ}ttj|jtj|ƒƒƒt|ƒS(s7Returns a new NDArray, detached from the current graph.(R RRtMXNDArrayDetachRwRRR2(R:R ((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytdetach1s "cC`sw|dkrtdƒg}n |jg}ttjdtt|jgƒtt|ƒtj|ƒtj|ƒƒƒdS(séCompute the gradients of this NDArray w.r.t variables. Parameters ---------- out_grad : NDArray, optional Gradient with respect to head. retain_graph : bool, optional Whether to retain the computaion graph for another backward pass on the same graph. By default the computaion history is cleared. train_mode : bool, optional Whether to compute gradient for training or inference. iiN( RxR RwRRtMXAutogradBackwardExRRR$(R:tout_gradt retain_grapht train_modet ograd_handles((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytbackward7s     N(ER8t __module__t__doc__t __slots__t__array_priority__R<R>RHRIRKRNRORQRSRURVRXRYR\R]R^R_RaRbReRgRhRjRlRnRpRrRtRut __nonzero__RvRR‡R¥R›RµR•RR‹R«RÂRÈtpropertyRÉR,RºR9R*RÔRÖtsetterR6RÛRÝR‘RäRšRëRêRîRxtFalseRâRô(((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR2Šs~                          p  F %   4 4     .    cC`stj||d|ƒS(stOne-hot encoding indices into matrix out. .. note:: `onehot_encode` is deprecated. Use `one_hot` instead. R?(RDt_onehot_encode(tindicesR?((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt onehot_encodeQscC`sOt|tƒr|f}n|dkr3tj}ntdt||t|ƒƒS(sReturns a new array of given shape and type, without initializing entries. Parameters ---------- shape : int or tuple of int The shape of the empty array. ctx : Context, optional An optional device context (default is the current default context). dtype : str or numpy.dtype, optional An optional value type (default is `float32`). Returns ------- NDArray A created array. Examples -------- >>> mx.nd.empty(1) >>> mx.nd.empty((1,2), mx.gpu(0)) >>> mx.nd.empty((1,2), mx.gpu(0), 'float16') RwN(RBRRxRt default_ctxR2R/Rü(R,R-R*((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRØ\s    cK`s7|dkrtj}ntjd|d|d||S(sReturns a new array filled with all zeros, with the given shape and type. Parameters ---------- shape : int or tuple of int The shape of the empty array. ctx : Context, optional An optional device context (default is the current default context). dtype : str or numpy.dtype, optional An optional value type (default is `float32`). out : NDArray, optional The output NDArray (default is `None`). Returns ------- NDArray A created array Examples -------- >>> mx.nd.zeros(1).asnumpy() array([ 0.], dtype=float32) >>> mx.nd.zeros((1,2), mx.gpu(0)) >>> mx.nd.zeros((1,2), mx.gpu(0), 'float16').asnumpy() array([[ 0., 0.]], dtype=float16) R,R-R*N(RxRRRDt_zeros(R,R-R*tkwargs((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytzeros|s  cK`s7|dkrtj}ntjd|d|d||S(sZReturns a new array filled with all ones, with the given shape and type. Parameters ---------- shape : int or tuple of int or list of int The shape of the empty array. ctx : Context, optional An optional device context. Defaults to the current default context (``mxnet.Context.default_ctx``). dtype : str or numpy.dtype, optional An optional value type (default is `float32`). out : NDArray, optional The output NDArray (default is `None`). Returns ------- NDArray A new array of the specified shape filled with all ones. Examples -------- >>> mx.nd.ones(1).asnumpy() array([ 1.], dtype=float32) >>> mx.nd.ones((1,2), mx.gpu(0)) >>> mx.nd.ones((1,2), dtype='float16').asnumpy() array([[ 1., 1.]], dtype=float16) R,R-R*N(RxRRRDt_ones(R,R-R*R((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytonesŸs  cC`s/|dkrt|||ƒn|}||(|S(s{Returns a new array of given shape and type, filled with the given value `val`. Parameters -------- shape : int or tuple of int The shape of the new array. val : scalar Fill value. ctx : Context, optional Device context (default is the current default context). dtype : `str` or `numpy.dtype`, optional The data type of the returned `NDArray`. The default datatype is `float32`. out : NDArray, optional The output NDArray (default is `None`). Returns ------- NDArray `NDArray` filled with `val`, with the given shape, ctx, and dtype. Examples -------- >>> mx.nd.full(1, 2.0).asnumpy() array([ 2.], dtype=float32) >>> mx.nd.full((1, 2), 2.0, mx.gpu(0)) >>> mx.nd.full((1, 2), 2.0, dtype='float16').asnumpy() array([[ 2., 2.]], dtype=float16) N(RxRØ(R,tvalR-R*R?((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytfullÃs$cC`s©t|tƒr-|dkr$|jn|}n\|dkr?tn|}t|tjƒs‰ytj|d|ƒ}Wq‰tdƒ‚q‰Xnt |j ||ƒ}||(|S(sÄCreates an array from any object exposing the array interface. Parameters ---------- source_array : array_like An object exposing the array interface, an object whose `__array__` method returns an array, or any (nested) sequence. ctx : Context, optional Device context (default is the current default context). dtype : str or numpy.dtype, optional The data type of the output array. The default dtype is ``source_array.dtype`` if `source_array` is an `NDArray`, `float32` otherwise. Returns ------- NDArray An `NDArray` with the same contents as the `source_array`. Examples -------- >>> import numpy as np >>> mx.nd.array([1, 2, 3]) >>> mx.nd.array([[1, 2], [3, 4]]) >>> mx.nd.array(np.zeros((3, 2))) >>> mx.nd.array(np.zeros((3, 2)), mx.gpu(0)) R*s&source_array must be array like objectN( RBR2RxR*R R)R“RRGRØR,(R»R-R*tarr((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRæscC`stt|jƒƒ}y|j|ƒWn!tk rItd|ƒ‚nXy|j||ƒWn!tk rtd|ƒ‚nXt||ƒS(s?Moves the `source` axis into the `destination` position while leaving the other axes in their original order Parameters ---------- tensor : mx.nd.array The array which axes should be reordered source : int Original position of the axes to move. destination : int Destination position for each of the original axes. Returns ------- result : mx.nd.array Array with moved axes. Examples -------- >>> X = mx.nd.array([[1, 2, 3], [4, 5, 6]]) >>> mx.nd.moveaxis(X, 0, 1).shape (3L, 2L) s4Source should verify 0 <= source < tensor.ndimGot %ds>Destination should verify 0 <= destination < tensor.ndimGot %d(R¦trangeRÉR©R±RARªRÓ(ttensortsourcet destinationtaxes((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytmoveaxiss  gð?cC`sL|dkrtj}ntjd|d|d|d|d|dt|ƒƒS(sÜReturns evenly spaced values within a given interval. Values are generated within the half-open interval [`start`, `stop`). In other words, the interval includes `start` but excludes `stop`. The function is similar to the built-in Python function `range` and to `numpy.arange`, but returns an `NDArray`. Parameters ---------- start : float, optional Start of interval. The default start value is 0. stop : float End of interval. step : float, optional Spacing between values. The default step size is 1. repeat : int, optional Number of times to repeat each element. The default repeat count is 1. ctx : Context, optional Device context. Default context is the current default context. dtype : str or numpy.dtype, optional The data type of the `NDArray`. The default datatype is `np.float32`. Returns ------- NDArray `NDArray` of evenly spaced values in the specified range. Examples -------- >>> mx.nd.arange(3).asnumpy() array([ 0., 1., 2.], dtype=float32) >>> mx.nd.arange(2, 6).asnumpy() array([ 2., 3., 4., 5.], dtype=float32) >>> mx.nd.arange(2, 6, step=2).asnumpy() array([ 2., 4.], dtype=float32) >>> mx.nd.arange(2, 6, step=1.5, repeat=2).asnumpy() array([ 2. , 2. , 3.5, 3.5, 5. , 5. ], dtype=float32) >>> mx.nd.arange(2, 6, step=2, repeat=3, dtype='int32').asnumpy() array([2, 2, 2, 4, 4, 4], dtype=int32) RŽRRtrepeatR*R-N(RxRRRDt_arangeR5(RŽRRRR-R*((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytarange:s)  !cC`s¾t|tƒr`t|tƒr+|||ƒS|dkrJ||t|ƒƒS||t|ƒƒSnZt|tƒr‚||t|ƒƒSt|tƒrž|||ƒStdtt|ƒƒƒ‚dS(sg Helper function for element-wise operation. The function will perform numpy-like broadcasting if needed and call different functions. Parameters -------- lhs : NDArray or numeric value Left-hand side operand. rhs : NDArray or numeric value Right-hand operand, fn_array : function Function to be called if both lhs and rhs are of ``NDArray`` type. fn_scalar : function Function to be called if both lhs and rhs are numeric values. lfn_scalar : function Function to be called if lhs is ``NDArray`` while rhs is numeric value rfn_scalar : function Function to be called if lhs is numeric value while rhs is ``NDArray``; if none is provided, then the function is commutative, so rfn_scalar is equal to lfn_scalar Returns -------- NDArray result array stype %s not supportedN(RBRRxRFR2RGR5R+(tlhstrhstfn_arrayt fn_scalart lfn_scalart rfn_scalar((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt _ufunc_helperjs   cC`st||ttjtjdƒS(sReturns element-wise sum of the input arrays with broadcasting. Equivalent to ``lhs + rhs``, ``mx.nd.broadcast_add(lhs, rhs)`` and ``mx.nd.broadcast_plus(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be added. rhs : scalar or array Second array to be added. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise sum of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x+2).asnumpy() array([[ 3., 3., 3.], [ 3., 3., 3.]], dtype=float32) >>> (x+y).asnumpy() array([[ 1., 1., 1.], [ 2., 2., 2.]], dtype=float32) >>> mx.nd.add(x,y).asnumpy() array([[ 1., 1., 1.], [ 2., 2., 2.]], dtype=float32) >>> (z + y).asnumpy() array([[ 0., 1.], [ 1., 2.]], dtype=float32) N(RRCtoperatorRRDRERx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR™s4cC`s"t||ttjtjtjƒS(s¹Returns element-wise difference of the input arrays with broadcasting. Equivalent to ``lhs - rhs``, ``mx.nd.broadcast_sub(lhs, rhs)`` and ``mx.nd.broadcast_minus(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be subtracted. rhs : scalar or array Second array to be subtracted. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise difference of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x-2).asnumpy() array([[-1., -1., -1.], [-1., -1., -1.]], dtype=float32) >>> (x-y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> mx.nd.subtract(x,y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> (z-y).asnumpy() array([[ 0., 1.], [-1., 0.]], dtype=float32) (RRLRtsubRDRMt_rminus_scalar(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRJÖs4cC`st||ttjtjdƒS(s’Returns element-wise product of the input arrays with broadcasting. Equivalent to ``lhs * rhs`` and ``mx.nd.broadcast_mul(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be multiplied. rhs : scalar or array Second array to be multiplied. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise multiplication of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x*2).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> (x*y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.multiply(x, y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> (z*y).asnumpy() array([[ 0., 0.], [ 0., 1.]], dtype=float32) N(RRTRtmulRDRRRx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRPs3cC`s"t||ttjtjtjƒS(sûReturns element-wise division of the input arrays with broadcasting. Equivalent to ``lhs / rhs`` and ``mx.nd.broadcast_div(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array in division. rhs : scalar or array Second array in division. The arrays to be divided. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise division of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3))*6 >>> y = mx.nd.ones((2,1))*2 >>> x.asnumpy() array([[ 6., 6., 6.], [ 6., 6., 6.]], dtype=float32) >>> y.asnumpy() array([[ 2.], [ 2.]], dtype=float32) >>> x/2 >>> (x/3).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> (x/y).asnumpy() array([[ 3., 3., 3.], [ 3., 3., 3.]], dtype=float32) >>> mx.nd.divide(x,y).asnumpy() array([[ 3., 3., 3.], [ 3., 3., 3.]], dtype=float32) (RRZRttruedivRDR[t _rdiv_scalar(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRWOs/cC`s"t||ttjtjtjƒS(søReturns element-wise modulo of the input arrays with broadcasting. Equivalent to ``lhs % rhs`` and ``mx.nd.broadcast_mod(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array in modulo. rhs : scalar or array Second array in modulo. The arrays to be taken modulo. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise modulo of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3))*6 >>> y = mx.nd.ones((2,1))*4 >>> x.asnumpy() array([[ 6., 6., 6.], [ 6., 6., 6.]], dtype=float32) >>> y.asnumpy() array([[ 4.], [ 4.]], dtype=float32) >>> x%5 >>> (x%5).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> (x%y).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> mx.nd.modulo(x,y).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) (RRcRtmodRDRdt _rmod_scalar(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR`‡s/cC`s"t||ttjtjtjƒS(s§Returns result of first array elements raised to powers from second array, element-wise with broadcasting. Equivalent to ``base ** exp`` and ``mx.nd.broadcast_power(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- base : scalar or NDArray The base array exp : scalar or NDArray The exponent array. If ``base.shape != exp.shape``, they must be broadcastable to a common shape. Returns -------- NDArray The bases in x raised to the exponents in y. Examples -------- >>> x = mx.nd.ones((2,3))*2 >>> y = mx.nd.arange(1,3).reshape((2,1)) >>> z = mx.nd.arange(1,3).reshape((2,1)) >>> x.asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> y.asnumpy() array([[ 1.], [ 2.]], dtype=float32) >>> z.asnumpy() array([[ 1.], [ 2.]], dtype=float32) >>> (x**2).asnumpy() array([[ 4., 4., 4.], [ 4., 4., 4.]], dtype=float32) >>> (x**y).asnumpy() array([[ 2., 2., 2.], [ 4., 4., 4.]], dtype=float32) >>> mx.nd.power(x,y).asnumpy() array([[ 2., 2., 2.], [ 4., 4., 4.]], dtype=float32) >>> (z**y).asnumpy() array([[ 1.], [ 4.]], dtype=float32) (Rtbroadcast_powerRtpowRDt _power_scalart_rpower_scalar(tbasetexp((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRf¿s4cC`st||td„tjdƒS(s,Returns element-wise maximum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_maximum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise maximum of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> mx.nd.maximum(x, 2).asnumpy() array([[ 2., 2., 2.], [ 2., 2., 2.]], dtype=float32) >>> mx.nd.maximum(x, y).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.maximum(y, z).asnumpy() array([[ 0., 1.], [ 1., 1.]], dtype=float32) cS`s||kr|S|S(N((R3ty((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt/sN(Rtbroadcast_maximumRDt_maximum_scalarRx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytmaximumüs/cC`st||td„tjdƒS(s,Returns element-wise minimum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_minimum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray The element-wise minimum of the input arrays. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> mx.nd.minimum(x, 2).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.minimum(x, y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.minimum(z, y).asnumpy() array([[ 0., 0.], [ 0., 1.]], dtype=float32) cS`s||kr|S|S(N((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(gsN(Rtbroadcast_minimumRDt_minimum_scalarRx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytminimum4s/cC`st||td„tjdƒS(sReturns the result of element-wise **equal to** (==) comparison operation with broadcasting. For each element in input arrays, return 1(true) if corresponding elements are same, otherwise return 0(false). Equivalent to ``lhs == rhs`` and ``mx.nd.broadcast_equal(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x == 1).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> (x == y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.equal(x,y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> (z == y).asnumpy() array([[ 1., 0.], [ 0., 1.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(¦sN(Rtbroadcast_equalRDt _equal_scalarRx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRils6cC`st||td„tjdƒS(szReturns the result of element-wise **not equal to** (!=) comparison operation with broadcasting. For each element in input arrays, return 1(true) if corresponding elements are different, otherwise return 0(false). Equivalent to ``lhs != rhs`` and ``mx.nd.broadcast_not_equal(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (z == y).asnumpy() array([[ 1., 0.], [ 0., 1.]], dtype=float32) >>> (x != 1).asnumpy() array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> (x != y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> mx.nd.not_equal(x, y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> (z != y).asnumpy() array([[ 0., 1.], [ 1., 0.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(èsN(Rtbroadcast_not_equalRDt_not_equal_scalarRx(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRk«s9cC`s"t||td„tjtjƒS(sReturns the result of element-wise **greater than** (>) comparison operation with broadcasting. For each element in input arrays, return 1(true) if lhs elements are greater than rhs, otherwise return 0(false). Equivalent to ``lhs > rhs`` and ``mx.nd.broadcast_greater(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x > 1).asnumpy() array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> (x > y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> mx.nd.greater(x, y).asnumpy() array([[ 1., 1., 1.], [ 0., 0., 0.]], dtype=float32) >>> (z > y).asnumpy() array([[ 0., 1.], [ 0., 0.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR('s(Rtbroadcast_greaterRDt_greater_scalart_lesser_scalar(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRmís6cC`s"t||td„tjtjƒS(s;Returns the result of element-wise **greater than or equal to** (>=) comparison operation with broadcasting. For each element in input arrays, return 1(true) if lhs elements are greater than equal to rhs, otherwise return 0(false). Equivalent to ``lhs >= rhs`` and ``mx.nd.broadcast_greater_equal(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x >= 1).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> (x >= y).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.greater_equal(x, y).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> (z >= y).asnumpy() array([[ 1., 1.], [ 0., 1.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(fs(Rtbroadcast_greater_equalRDt_greater_equal_scalart_lesser_equal_scalar(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRo,s6cC`s"t||td„tjtjƒS(sReturns the result of element-wise **lesser than** (<) comparison operation with broadcasting. For each element in input arrays, return 1(true) if lhs elements are less than rhs, otherwise return 0(false). Equivalent to ``lhs < rhs`` and ``mx.nd.broadcast_lesser(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x < 1).asnumpy() array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> (x < y).asnumpy() array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> mx.nd.lesser(x, y).asnumpy() array([[ 0., 0., 0.], [ 0., 0., 0.]], dtype=float32) >>> (z < y).asnumpy() array([[ 0., 0.], [ 1., 0.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(¥s(Rtbroadcast_lesserRDR5R4(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRqks6cC`s"t||td„tjtjƒS(s7Returns the result of element-wise **lesser than or equal to** (<=) comparison operation with broadcasting. For each element in input arrays, return 1(true) if lhs elements are lesser than equal to rhs, otherwise return 0(false). Equivalent to ``lhs <= rhs`` and ``mx.nd.broadcast_lesser_equal(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ---------- lhs : scalar or array First array to be compared. rhs : scalar or array Second array to be compared. If ``lhs.shape != rhs.shape``, they must be broadcastable to a common shape. Returns ------- NDArray Output array of boolean values. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.arange(2).reshape((2,1)) >>> z = mx.nd.arange(2).reshape((1,2)) >>> x.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.asnumpy() array([[ 0.], [ 1.]], dtype=float32) >>> z.asnumpy() array([[ 0., 1.]], dtype=float32) >>> (x <= 1).asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> (x <= y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> mx.nd.lesser_equal(x, y).asnumpy() array([[ 0., 0., 0.], [ 1., 1., 1.]], dtype=float32) >>> (z <= y).asnumpy() array([[ 1., 0.], [ 1., 1.]], dtype=float32) cS`s||krdSdS(Nii((R3R'((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyR(ås(Rtbroadcast_lesser_equalRDR8R7(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyRs«s6cC`s t||ƒS(s0This function is similar to :meth:`divide`. (RW(RR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pyt true_divideêscC`s t|dƒS(sRNumerical negative, element-wise. Equals ``-arr`` Parameters ---------- arr : NDArray The input array Returns ------- NDArray ``-arr`` Examples -------- >>> x = mx.nd.ones((2,3)) >>> (-x).asnumpy() array([[-1., -1., -1.], [-1., -1., -1.]], dtype=float32) gð¿(RP(R((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytnegativeðsc`s!t|tƒstdƒ‚ntƒ}tƒ}tjtƒƒ‰tjtjƒƒ‰tt j t |ƒtj |ƒtj ˆƒtj |ƒtj ˆƒƒƒ|j dkrßgt|j ƒD]}ttˆ|ƒƒ^q¿S|j |j ks÷t‚t‡‡fd†t|j ƒDƒƒSdS(sâLoads an array from file. See more details in ``save``. Parameters ---------- fname : str The filename. Returns ------- list of NDArray or dict of str to NDArray Loaded data. sfname required to be a stringic3`s5|]+}tˆ|ƒttˆ|ƒƒfVqdS(N(RR2R (t.0R£(thandlestnames(s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pys ( sN(RBRRGR RRzR tc_char_pRRt MXNDArrayLoadR RR}R R2R—tdict(tfnametout_sizet out_name_sizeR£((R>R?s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytload s      0cC`set|tƒr|g}ng}t|tƒrÇg}xy|jƒD]k\}}t|tƒsmtdƒ‚nt|tƒs‹tdƒ‚n|jt|ƒƒ|j|jƒqCWt t j |ƒ}nct|t ƒrx<|D]4}t|tƒstdƒ‚n|j|jƒqÝWd}n tdƒ‚ttjt|ƒtt|ƒƒt t|ƒ|ƒƒdS(søSaves a list of arrays or a dict of str->array to file. Examples of filenames: - ``/path/to/file`` - ``s3://my-bucket/path/to/file`` (if compiled with AWS S3 supports) - ``hdfs://path/to/file`` (if compiled with HDFS supports) Parameters ---------- fname : str The filename. data : ``NDArray``, list of ``NDArray` or dict of str to ``NDArray`` The data to save. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> y = mx.nd.ones((1,4)) >>> mx.nd.save('my_list', [x,y]) >>> mx.nd.save('my_dict', {'x':x, 'y':y}) >>> mx.nd.load('my_list') [, ] >>> mx.nd.load('my_dict') {'y': , 'x': } s5save only accept dict str->NDArray or list of NDArraysTdata needs to either be a NDArray, dict of str, NDArray pairs or a list of NDarrays.N(RBR2RBtitemsRRGR™R RwRRR@R¦RxRARRt MXNDArraySaveR R#R (RCRÚR>tkeysRžR((s-build/bdist.linux-armv7l/egg/mxnet/ndarray.pytsave+ s0     c C`st|tƒst‚t|ƒdks-t‚t|dtƒsFt‚| rgt|ƒdkrg|dS|dj|}|djd|!}|dj|d}|dj}xq|dD]e}||j|7}||jd|!ksìt‚||j|dks t‚||jks¹t‚q¹W||f|}t|d|djd|ƒ} d} g|D] } d^q_} t|ƒ} x“|D]‹}|dkr±|| | | |jd+nM| | |<| |j|| |s¼       "("! !                  ÿÿÿÊ  #$#- '0 / = = < 8 8 = 8 8 ? B ? ? @ ?   " 78$+ {