ó ùµÈ[c@s€dZddddgZddlZdefd„ƒYZdefd„ƒYZdefd „ƒYZdefd „ƒYZdS( sDataset sampler.tSamplertSequentialSamplert RandomSamplert BatchSampleriÿÿÿÿNcBs eZdZd„Zd„ZRS(szBase class for samplers. All samplers should subclass `Sampler` and define `__iter__` and `__len__` methods. cCs t‚dS(N(tNotImplementedError(tself((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyt__iter__scCs t‚dS(N(R(R((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyt__len__"s(t__name__t __module__t__doc__RR(((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRs cBs)eZdZd„Zd„Zd„ZRS(s„Samples elements from [0, length) sequentially. Parameters ---------- length : int Length of the sequence. cCs ||_dS(N(t_length(Rtlength((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyt__init__.scCstt|jƒƒS(N(titertrangeR (R((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR1scCs|jS(N(R (R((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR4s(RR R R RR(((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR&s  cBs)eZdZd„Zd„Zd„ZRS(s”Samples elements from [0, length) randomly without replacement. Parameters ---------- length : int Length of the sequence. cCs ||_dS(N(R (RR ((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR @scCs,tj|jƒ}tjj|ƒt|ƒS(N(tnptarangeR trandomtshuffleR(Rtindices((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRCscCs|jS(N(R (R((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRHs(RR R R RR(((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR8s  cBs,eZdZdd„Zd„Zd„ZRS(sZWraps over another `Sampler` and return mini-batches of samples. Parameters ---------- sampler : Sampler The source Sampler. batch_size : int Size of mini-batch. last_batch : {'keep', 'discard', 'rollover'} Specifies how the last batch is handled if batch_size does not evenly divide sequence length. If 'keep', the last batch will be returned directly, but will contain less element than `batch_size` requires. If 'discard', the last batch will be discarded. If 'rollover', the remaining elements will be rolled over to the next iteration. Examples -------- >>> sampler = gluon.data.SequentialSampler(10) >>> batch_sampler = gluon.data.BatchSampler(sampler, 3, 'keep') >>> list(batch_sampler) [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]] tkeepcCs(||_||_||_g|_dS(N(t_samplert _batch_sizet _last_batcht_prev(Rtsamplert batch_sizet last_batch((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyR hs   ccs¼|jg}|_xA|jD]6}|j|ƒt|ƒ|jkr|Vg}qqW|r¸|jdkrt|Vq¸|jdkr‡dS|jdkr¢||_q¸td|jƒ‚ndS(NRtdiscardtrolloversFlast_batch must be one of 'keep', 'discard', or 'rollover', but got %s(RRtappendtlenRRt ValueError(Rtbatchti((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRns    cCs˜|jdkr.t|jƒ|jd|jS|jdkrQt|jƒ|jS|jdkrt|jƒt|jƒ|jStd|jƒ‚dS(NRiRRsFlast_batch must be one of 'keep', 'discard', or 'rollover', but got %s(RR RRRR!(R((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRs!(RR R R RR(((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyRLs  ( R t__all__tnumpyRtobjectRRRR(((sX/usr/local/lib/python2.7/site-packages/mxnet-1.3.1-py2.7.egg/mxnet/gluon/data/sampler.pyts