public static List<DataSet> loadPPTest(int from, int to) throws IOException { ClassPathResource resource = new ClassPathResource("/pptest.dat"); @SuppressWarnings("unchecked") List<String> lines = IOUtils.readLines(resource.getInputStream()); List<DataSet> list = new ArrayList<>(); INDArray ret = Nd4j.ones(Math.abs(to - from), 4); double[][] outcomes = new double[lines.size()][3]; int putCount = 0; for (int i = from; i < to; i++) { String line = lines.get(i); String[] split = line.split(","); addRow(ret, putCount++, split); String outcome = split[split.length - 1]; double[] rowOutcome = new double[3]; rowOutcome[Integer.parseInt(outcome)] = 1; outcomes[i] = rowOutcome; } for (int i = 0; i < ret.rows(); i++) { DataSet add = new DataSet(ret.getRow(i), Nd4j.create(outcomes[from + i])); list.add(add); } return list; }
@Test public void testLoader() throws Exception { Nd4j.dtype = DataBuffer.Type.DOUBLE; KernelFunctionLoader loader = KernelFunctionLoader.getInstance(); loader.load(); ClassPathResource res = new ClassPathResource( "/cudafunctions.properties", KernelFunctionLoader.class.getClassLoader()); if (!res.exists()) throw new IllegalStateException("Please put a cudafunctions.properties in your class path"); Properties props = new Properties(); props.load(res.getInputStream()); loader.unload(); }