Package org.datavec.image.loader
Class CifarLoader
- java.lang.Object
-
- org.datavec.image.loader.BaseImageLoader
-
- org.datavec.image.loader.NativeImageLoader
-
- org.datavec.image.loader.CifarLoader
-
- All Implemented Interfaces:
Serializable
public class CifarLoader extends NativeImageLoader implements Serializable
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.datavec.image.loader.BaseImageLoader
BaseImageLoader.MultiPageMode
-
-
Field Summary
Fields Modifier and Type Field Description static intCHANNELSstatic Map<String,String>cifarDataMapstatic booleanDEFAULT_SHUFFLEstatic booleanDEFAULT_USE_SPECIAL_PREPROCprotected intfileNumprotected FilefullDirstatic intHEIGHTprotected InputStreaminputStreamprotected List<String>labelsprotected DataSetloadDSprotected intloadDSIndexprotected booleanmeanStdStoredprotected FilemeanVarPathstatic intNUM_LABELSstatic intNUM_TEST_IMAGESstatic intNUM_TRAIN_IMAGESprotected intnumExamplesprotected longseedprotected booleanshuffleprotected StringtestFilesSerializedprotected InputStreamtestInputStreamprotected booleantrainprotected StringtrainFilesSerializedprotected InputStreamtrainInputStreamprotected doubleuMeanprotected booleanuseSpecialPreProcessCifarprotected doubleuStdprotected doublevMeanprotected doublevStdstatic intWIDTH-
Fields inherited from class org.datavec.image.loader.NativeImageLoader
ALLOWED_FORMATS, converter
-
Fields inherited from class org.datavec.image.loader.BaseImageLoader
centerCropIfNeeded, channels, height, imageTransform, multiPageMode, rng, width
-
-
Constructor Summary
Constructors Constructor Description CifarLoader()CifarLoader(boolean train)CifarLoader(boolean train, File fullPath)CifarLoader(int height, int width, int channels, boolean train, boolean useSpecialPreProcessCifar)CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar)CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar, boolean shuffle)CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar, File fullDir, long seed, boolean shuffle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description INDArrayasMatrix(File f)As perBaseImageLoader.asMatrix(File, boolean)but NCHW/channels_first formatINDArrayasMatrix(InputStream inputStream)INDArrayasRowVector(File f)Convert a file to a row vectorINDArrayasRowVector(InputStream inputStream)org.bytedeco.opencv.opencv_core.MatconvertCifar(org.bytedeco.opencv.opencv_core.Mat orgImage)Preprocess and store cifar based on successful Torch approach by Sergey Zagoruyko Reference: https://github.com/szagoruyko/cifar.torchDataSetconvertDataSet(int num)org.nd4j.common.primitives.Pair<INDArray,org.bytedeco.opencv.opencv_core.Mat>convertMat(byte[] byteFeature)InputStreamgetInputStream()List<String>getLabels()protected voidload()DataSetnext(int batchSize)DataSetnext(int batchSize, int exampleNum)voidnormalizeCifar(File fileName)Normalize and store cifar based on successful Torch approach by Sergey Zagoruyko Reference: https://github.com/szagoruyko/cifar.torchvoidreset()voidsetInputStream()doublevarManual(INDArray x, double mean)-
Methods inherited from class org.datavec.image.loader.NativeImageLoader
asFrame, asFrame, asImageMatrix, asImageMatrix, asImageMatrix, asImageMatrix, asImageMatrix, asMat, asMat, asMatrix, asMatrix, asMatrix, asMatrix, asMatrix, asMatrix, asMatrix, asMatrix, asMatrixView, asMatrixView, asMatrixView, asMatrixView, asMatrixView, asRowVector, asRowVector, asRowVector, asRowVector, asRowVector, asWritable, asWritable, centerCropIfNeeded, fillNDArray, getAllowedFormats, scalingIfNeed, scalingIfNeed, transformImage, transformImage
-
Methods inherited from class org.datavec.image.loader.BaseImageLoader
downloadAndUntar
-
-
-
-
Field Detail
-
NUM_TRAIN_IMAGES
public static final int NUM_TRAIN_IMAGES
- See Also:
- Constant Field Values
-
NUM_TEST_IMAGES
public static final int NUM_TEST_IMAGES
- See Also:
- Constant Field Values
-
NUM_LABELS
public static final int NUM_LABELS
- See Also:
- Constant Field Values
-
HEIGHT
public static final int HEIGHT
- See Also:
- Constant Field Values
-
WIDTH
public static final int WIDTH
- See Also:
- Constant Field Values
-
CHANNELS
public static final int CHANNELS
- See Also:
- Constant Field Values
-
DEFAULT_USE_SPECIAL_PREPROC
public static final boolean DEFAULT_USE_SPECIAL_PREPROC
- See Also:
- Constant Field Values
-
DEFAULT_SHUFFLE
public static final boolean DEFAULT_SHUFFLE
- See Also:
- Constant Field Values
-
fullDir
protected final File fullDir
-
meanVarPath
protected final File meanVarPath
-
trainFilesSerialized
protected final String trainFilesSerialized
-
testFilesSerialized
protected final String testFilesSerialized
-
inputStream
protected InputStream inputStream
-
trainInputStream
protected InputStream trainInputStream
-
testInputStream
protected InputStream testInputStream
-
train
protected boolean train
-
useSpecialPreProcessCifar
protected boolean useSpecialPreProcessCifar
-
seed
protected long seed
-
shuffle
protected boolean shuffle
-
numExamples
protected int numExamples
-
uMean
protected double uMean
-
uStd
protected double uStd
-
vMean
protected double vMean
-
vStd
protected double vStd
-
meanStdStored
protected boolean meanStdStored
-
loadDSIndex
protected int loadDSIndex
-
loadDS
protected DataSet loadDS
-
fileNum
protected int fileNum
-
-
Constructor Detail
-
CifarLoader
public CifarLoader()
-
CifarLoader
public CifarLoader(boolean train)
-
CifarLoader
public CifarLoader(boolean train, File fullPath)
-
CifarLoader
public CifarLoader(int height, int width, int channels, boolean train, boolean useSpecialPreProcessCifar)
-
CifarLoader
public CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar)
-
CifarLoader
public CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar, boolean shuffle)
-
CifarLoader
public CifarLoader(int height, int width, int channels, ImageTransform imgTransform, boolean train, boolean useSpecialPreProcessCifar, File fullDir, long seed, boolean shuffle)
-
-
Method Detail
-
asRowVector
public INDArray asRowVector(File f) throws IOException
Description copied from class:NativeImageLoaderConvert a file to a row vector- Overrides:
asRowVectorin classNativeImageLoader- Parameters:
f- the image to convert- Returns:
- the flattened image
- Throws:
IOException
-
asRowVector
public INDArray asRowVector(InputStream inputStream) throws IOException
- Overrides:
asRowVectorin classNativeImageLoader- Throws:
IOException
-
asMatrix
public INDArray asMatrix(File f) throws IOException
Description copied from class:BaseImageLoaderAs perBaseImageLoader.asMatrix(File, boolean)but NCHW/channels_first format- Overrides:
asMatrixin classNativeImageLoader- Throws:
IOException
-
asMatrix
public INDArray asMatrix(InputStream inputStream) throws IOException
- Overrides:
asMatrixin classNativeImageLoader- Throws:
IOException
-
load
protected void load()
-
convertCifar
public org.bytedeco.opencv.opencv_core.Mat convertCifar(org.bytedeco.opencv.opencv_core.Mat orgImage)
Preprocess and store cifar based on successful Torch approach by Sergey Zagoruyko Reference: https://github.com/szagoruyko/cifar.torch
-
normalizeCifar
public void normalizeCifar(File fileName)
Normalize and store cifar based on successful Torch approach by Sergey Zagoruyko Reference: https://github.com/szagoruyko/cifar.torch
-
convertMat
public org.nd4j.common.primitives.Pair<INDArray,org.bytedeco.opencv.opencv_core.Mat> convertMat(byte[] byteFeature)
-
convertDataSet
public DataSet convertDataSet(int num)
-
varManual
public double varManual(INDArray x, double mean)
-
next
public DataSet next(int batchSize)
-
next
public DataSet next(int batchSize, int exampleNum)
-
getInputStream
public InputStream getInputStream()
-
setInputStream
public void setInputStream()
-
reset
public void reset()
-
-