Java Path File List nio loadTrainingData(Path path, List input, List output, int outputCount)

Here you can find the source of loadTrainingData(Path path, List input, List output, int outputCount)

Description

load Training Data

License

Open Source License

Declaration

public static void loadTrainingData(Path path, List<float[]> input, List<float[]> output, int outputCount)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Random;

public class Main {
    public static void loadTrainingData(Path path, List<float[]> input, List<float[]> output, int outputCount)
            throws IOException {
        List<String> lines = Files.readAllLines(path);
        Collections.shuffle(lines, new Random(System.nanoTime()));
        for (int i = 0; i < lines.size(); i++) {
            String[] pieces = lines.get(i).split("\\s");
            float[] tmpInput = new float[pieces.length - outputCount];
            float[] tmpOutput = new float[outputCount];
            for (int k = 0; k < pieces.length - outputCount; k++) {
                tmpInput[k] = Float.parseFloat(pieces[k]);
            }/*from   w ww . java  2 s  .  c om*/
            for (int k = 0; k < outputCount; k++) {
                tmpOutput[k] = Float.parseFloat(pieces[k + (pieces.length - outputCount)]);
            }
            input.add(tmpInput);
            output.add(tmpOutput);
        }
    }
}

Related

  1. listFilesRecursively(Path dir, final DirectoryStream.Filter filter, final boolean recursive)
  2. listFoldersInFolder2(String path)
  3. listOfWords(String filePath)
  4. listSteps(Path scenarioDirectory)
  5. loadDataFilesList(String prefix, Path bwcIndicesPath)
  6. mergeFiles(List files, Path mergedFile)
  7. mergeInto(List parts, OutputStream out)
  8. pathContainsAny(List strings)
  9. recursiveListFiles(Path file)