Package ml.shifu.guagua.example.nn
Class MemoryDiskMLDataSet
- java.lang.Object
-
- ml.shifu.guagua.example.nn.MemoryDiskMLDataSet
-
- All Implemented Interfaces:
Iterable<org.encog.ml.data.MLDataPair>,org.encog.ml.data.MLDataSet
public class MemoryDiskMLDataSet extends Object implements org.encog.ml.data.MLDataSet
A hybrid data set combiningBasicMLDataSetandBufferedMLDataSettogether.With this data set, element is added firstly in memory, if over
maxByteSizethen element will be added into disk.This data set provide a very important feature to make in memory computing more stable. Even for some cases no enough memory, memory and disk will be leveraged together to accelerate computing.
Example almost same as
BufferedMLDataSet:MemoryDiskMLDataSet dataSet = new MemoryDiskMLDataSet(400, "a.txt"); dataSet.beginLoad(10, 1); dataSet.add(pair); dataSet.endLoad(); Iterator
iterator = dataSet.iterator(); while(iterator.hasNext()) { MLDataPair next = iterator.next(); ... } dataSet.close(); - Author:
- Zhang David (pengzhang@paypal.com)
-
-
Constructor Summary
Constructors Constructor Description MemoryDiskMLDataSet(long maxByteSize, String fileName)Constructor withmaxByteSizeandfileNameMemoryDiskMLDataSet(long maxByteSize, String fileName, int inputCount, int outputCount)MemoryDiskMLDataSet(String fileName, int inputCount, int outputCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(org.encog.ml.data.MLData data)voidadd(org.encog.ml.data.MLDataPair inputData)voidadd(org.encog.ml.data.MLData inputData, org.encog.ml.data.MLData idealData)voidbeginLoad(int inputSize, int idealSize)Setting input variable size and output target size.voidclose()voidendLoad()This method should be called once all the data has been loaded.longgetDiskCount()intgetIdealSize()intgetInputSize()longgetMemoryCount()voidgetRecord(long index, org.encog.ml.data.MLDataPair pair)longgetRecordCount()booleanisSupervised()Iterator<org.encog.ml.data.MLDataPair>iterator()static voidmain(String[] args)org.encog.ml.data.MLDataSetopenAdditional()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
MemoryDiskMLDataSet
public MemoryDiskMLDataSet(String fileName, int inputCount, int outputCount)
-
MemoryDiskMLDataSet
public MemoryDiskMLDataSet(long maxByteSize, String fileName)Constructor withmaxByteSizeandfileName
-
MemoryDiskMLDataSet
public MemoryDiskMLDataSet(long maxByteSize, String fileName, int inputCount, int outputCount)
-
-
Method Detail
-
beginLoad
public final void beginLoad(int inputSize, int idealSize)Setting input variable size and output target size.- Parameters:
inputSize- input variable sizeidealSize- output target size
-
endLoad
public final void endLoad()
This method should be called once all the data has been loaded. The underlying file will be closed. The binary fill will then be opened for reading.
-
iterator
public Iterator<org.encog.ml.data.MLDataPair> iterator()
-
getIdealSize
public int getIdealSize()
- Specified by:
getIdealSizein interfaceorg.encog.ml.data.MLDataSet
-
getInputSize
public int getInputSize()
- Specified by:
getInputSizein interfaceorg.encog.ml.data.MLDataSet
-
isSupervised
public boolean isSupervised()
- Specified by:
isSupervisedin interfaceorg.encog.ml.data.MLDataSet
-
getRecordCount
public long getRecordCount()
- Specified by:
getRecordCountin interfaceorg.encog.ml.data.MLDataSet
-
getRecord
public void getRecord(long index, org.encog.ml.data.MLDataPair pair)- Specified by:
getRecordin interfaceorg.encog.ml.data.MLDataSet
-
openAdditional
public org.encog.ml.data.MLDataSet openAdditional()
- Specified by:
openAdditionalin interfaceorg.encog.ml.data.MLDataSet
-
add
public void add(org.encog.ml.data.MLData data)
- Specified by:
addin interfaceorg.encog.ml.data.MLDataSet
-
add
public void add(org.encog.ml.data.MLData inputData, org.encog.ml.data.MLData idealData)- Specified by:
addin interfaceorg.encog.ml.data.MLDataSet
-
add
public void add(org.encog.ml.data.MLDataPair inputData)
- Specified by:
addin interfaceorg.encog.ml.data.MLDataSet
-
close
public void close()
- Specified by:
closein interfaceorg.encog.ml.data.MLDataSet
-
getMemoryCount
public long getMemoryCount()
- Returns:
- the memoryCount
-
getDiskCount
public long getDiskCount()
- Returns:
- the diskCount
-
main
public static void main(String[] args)
-
-