public static NDArrayIter FromBatch(DataBatch data_batch) { var iter = new NDArrayIter(data_batch.Data, data_batch.Label); iter.DefaultBucketKey = data_batch.BucketKey.HasValue ? data_batch.BucketKey.Value : new Random().Next(); return(iter); }
public MXDataIter(DataIterHandle handle, string data_name = "data", string label_name = "softmax_label") { this.handle = handle; _debug_skip_load = false; first_batch = Next(); data = first_batch.Data[0]; label = first_batch.Label[0]; BatchSize = data.Shape[0]; op = new Operator(handle); }
public MXDataIter(string mxdataiterType, string data_name = "data", string label_name = "softmax_label") { handle = DataIterMap.GetMXDataIterCreator(mxdataiterType); _debug_skip_load = false; first_batch = Next(); data = first_batch.Data[0]; label = first_batch.Label[0]; this.data_name = data_name; this.label_name = label_name; BatchSize = data.Shape[0]; op = new Operator(handle); }
public override DataBatch Next() { if (_debug_skip_load && !_debug_at_begin) { return(new DataBatch(GetData(), GetLabel(), GetPad(), GetIndex())); } if (first_batch != null) { var batch = first_batch; first_batch = null; return(batch); } _debug_at_begin = false; next_res = 0; NativeMethods.MXDataIterNext(handle, out next_res); if (next_res.HasValue) { return(new DataBatch(GetData(), GetLabel(), GetPad(), GetIndex())); } throw new MXNetException("Stop Iteration"); }
public override void Reset() { _debug_at_begin = true; first_batch = null; NativeMethods.MXDataIterBeforeFirst(handle); }