This answer expects some baseline knowledge of the framework. If you are unsure, please ensure to take a look at our quickstart and examples: https://deeplearning4j.konduit.ai/ We also have examples at https://github.com/deeplearning4j/deeplearning4j-examples - please ensure you take a look at those. Please feel free to ask questions about those as well.
What you're looking for is a configuration similar to:
final int numHiddenNodes = 50;
return new NeuralNetConfiguration.Builder()
.seed(seed)
.weightInit(WeightInit.XAVIER)
.updater(new Nesterovs(learningRate, 0.9))
.list()
.layer(0, new DenseLayer.Builder().nIn(numInputs).nOut(numHiddenNodes)
.activation(Activation.TANH).build())
.layer(1, new DenseLayer.Builder().nIn(numHiddenNodes).nOut(numHiddenNodes)
.activation(Activation.TANH).build())
.layer(2, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
.activation(Activation.IDENTITY)
.nIn(numHiddenNodes).nOut(numOutputs).build())
.build();
This will give you a neural network with an MSE loss function and an identity output. This is a good starting point ( no guarantees of accuracy, it's very much problem dependent) for regression.
Afterwards, ensure you setup a neural network data set iterator for regression.
You can prepare your input data using something like:
int numLinesToSkip = 0;
String fileDelimiter = ",";
RecordReader rr = new CSVRecordReader(numLinesToSkip,fileDelimiter);
String csvPath = "/path/to/my/file.csv";
rr.initialize(new FileSplit(new File(csvPath)));
int batchSize = 4;
RecordReaderDataSetIterator testIterator = new RecordReaderDataSetIterator.Builder(rr, batchSize)
.regression(3)
.build();
Note the regression method is for telling the dataset iterator to treat the value at column 3 as your label. You will need to change this to suit your problem.
Depending on your data you might need to normalize it. In that case ensure you also apply a normalizer:
NormalizerStandardize std = new NormalizerStandardize();
std.fit(iter);
iter.setPreProcessor(std);
This will fit a zero mean unit variance normalizer to your data.