Overview
DataVec ETL framework — purpose, architecture, and the data pipeline from raw data to DataSet
DataVec is the data transformation and vectorization library for the Eclipse Deeplearning4j ecosystem. It solves one of the most common obstacles in applied machine learning: getting raw data into the format that neural networks expect. Neural networks consume vectors and tensors, but raw data comes as CSV files, images on disk, log lines, JSON documents, and dozens of other formats. DataVec provides the tooling to bridge that gap.
The name reflects its mission: DataVec = Data Vectorization.
What DataVec Does
DataVec handles the Extract, Transform, Load (ETL) phase of a machine learning workflow:
Extract: Read data from files, directories, in-memory collections, or distributed storage using
RecordReaderimplementations.Transform: Apply an ordered sequence of operations — type conversions, column manipulations, categorical encoding, filtering, normalization — via
TransformProcess.Load: Deliver the processed data as
DataSetobjects to DL4J model training viaDataSetIterator.
DataVec also integrates with Apache Spark, so the same transform definitions can run locally on a developer laptop or distributed across a cluster without code changes.
When to Use DataVec
Use DataVec when:
Your data is in CSV, TSV, JSON, XML, or other structured text formats
Your data is a labeled image directory and you need to feed images into a CNN
You need to convert categorical string columns to one-hot or integer representations
You need to filter out bad records, normalize numeric columns, or parse timestamps
You want a reusable, serializable transformation pipeline that can run both offline and in production inference
You may not need DataVec if:
Your data is already in a numeric NDArray format that maps directly to your model inputs
You are only loading simple pre-formatted datasets (e.g., MNIST via the built-in fetcher)
Core Pipeline
The standard DataVec pipeline has four stages:
Stage 1: InputSplit
An InputSplit tells the RecordReader where the data lives. Common splits:
FileSplit(File rootDir)— all files under a directory, recursivelyFileSplit(File rootDir, String[] allowedExtensions, Random rng)— filtered by extensionNumberedFileInputSplit(String basePattern, int minIdx, int maxIdx)— for numbered files likerecord_0001.csvthroughrecord_9999.csvCollectionInputSplit(List<URI> uris)— from an arbitrary list of URIsInputStreamInputSplit(InputStream is)— from any input stream
Stage 2: RecordReader
A RecordReader iterates over the InputSplit and converts each unit of data (a line, a file, a JSON object) into a List<Writable>. Each Writable in the list corresponds to one column.
DataVec ships with readers for CSV, JSON/XML/YAML, images, log lines, audio, LibSVM, and more. See Record Readers for the full list.
Stage 3: TransformProcess
A TransformProcess is an ordered list of operations applied to each record, defined against a Schema that describes the layout of the input data.
The transform process validates each operation against the schema at build time, so errors (referencing a non-existent column, applying a numeric op to a String column, etc.) are caught before any data is processed.
Stage 4: DataSetIterator
Once you have a reader and optionally a transform process, wrap them in a RecordReaderDataSetIterator to produce DataSet objects that DL4J can train on directly.
Supported Data Formats
DataVec has built-in support for:
CSV / TSV
CSVRecordReader
CSV sequences (one file per sequence)
CSVSequenceRecordReader
JSON, XML, YAML
JacksonRecordReader
Log lines (regex parsing)
RegexLineRecordReader
Raw text lines
LineRecordReader
Labeled images (directory structure)
ImageRecordReader
LibSVM sparse format
LibSvmRecordReader
SVMLight format
SVMLightRecordReader
MATLAB .mat files
MatlabRecordReader
Apache Arrow columnar
ArrowRecordReader
WAV audio
WavFileRecordReader
TF-IDF vectors
TfidfRecordReader
In-memory collections
CollectionRecordReader
Architecture
DataVec is organized into several Maven modules:
datavec-api— core interfaces:RecordReader,Writable,Schema,TransformProcess,Filter,Conditiondatavec-local— local (non-Spark) executors:LocalTransformExecutor,AnalyzeLocaldatavec-spark— Spark executors:SparkTransformExecutor,AnalyzeSparkdatavec-data-image— image readers:ImageRecordReader,NativeImageLoaderdatavec-data-audio— audio readersdatavec-data-nlp— NLP readers including TF-IDFdatavec-arrow— Apache Arrow integration
Data Types
DataVec uses a typed column model. Every column in a Schema has a ColumnType:
Integer— 32-bit signed integerLong— 64-bit signed integerDouble— 64-bit floating pointFloat— 32-bit floating pointString— arbitrary textCategorical— a fixed set of string labels (like an enum)Time— stored as epoch milliseconds (Long), but carries timezone infoBytes— raw byte arrayNDArray— an embedded multidimensional arrayBoolean— true/false
At the record level, each column is stored as a Writable — a lightweight value holder. IntWritable, DoubleWritable, Text, NDArrayWritable, etc. implement this interface.
A Complete Example
Here is a concise end-to-end example loading a CSV, applying transforms, and producing a DataSet:
Relationship to Other DL4J Components
ND4J: DataVec's output is eventually consumed as ND4J
INDArrayobjects.NDArrayWritablebridges the two.DL4J:
RecordReaderDataSetIterator(and related iterators) wrap DataVec readers to produceDataSetandMultiDataSetobjects that DL4JMultiLayerNetworkandComputationGraphconsume.SameDiff: SameDiff training also accepts
DataSetIterator, so DataVec pipelines work unchanged.Spark:
SparkTransformExecutorlets you apply the sameTransformProcessto a SparkJavaRDD<List<Writable>>.
Further Reading
Schema — defining the structure of your data
Record Readers — reading different file formats
Transforms — the full transform API
Normalization — scaling and standardizing features
Executors — running transforms locally or on Spark
Image Data — image-specific pipeline
Last updated
Was this helpful?