Java Code Examples for org.nd4j.linalg.dataset.DataSet#detach()
The following examples show how to use
org.nd4j.linalg.dataset.DataSet#detach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsyncDataSetIteratorTest.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Test public void testVariableTimeSeries2() throws Exception { AsyncDataSetIterator adsi = new AsyncDataSetIterator(new VariableTimeseriesGenerator(1192, 100, 32, 128, 100, 100, 100), 2, true, new InterleavedDataSetCallback(2 * 2)); for (int e = 0; e < 5; e++) { int cnt = 0; while (adsi.hasNext()) { DataSet ds = adsi.next(); ds.detach(); //log.info("Features ptr: {}", AtomicAllocator.getInstance().getPointer(mds.getFeatures()[0].data()).address()); assertEquals("Failed on epoch " + e + "; iteration: " + cnt + ";", (double) cnt, ds.getFeatures().meanNumber().doubleValue(), 1e-10); assertEquals("Failed on epoch " + e + "; iteration: " + cnt + ";", (double) cnt + 0.25, ds.getLabels().meanNumber().doubleValue(), 1e-10); assertEquals("Failed on epoch " + e + "; iteration: " + cnt + ";", (double) cnt + 0.5, ds.getFeaturesMaskArray().meanNumber().doubleValue(), 1e-10); assertEquals("Failed on epoch " + e + "; iteration: " + cnt + ";", (double) cnt + 0.75, ds.getLabelsMaskArray().meanNumber().doubleValue(), 1e-10); cnt++; } adsi.reset(); // log.info("Epoch {} finished...", e); } }
Example 2
Source File: WorkspacesShieldDataSetIterator.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Override public DataSet next() { DataSet ds = iterator.next(); if (ds.getFeatures().isAttached()) { if (Nd4j.getMemoryManager().getCurrentWorkspace() == null) { ds.detach(); } else { ds.migrate(); } } return ds; }