/** * Create table output. * * @param rows the rows * @return the table output */ @javax.annotation.Nonnull public static TableOutput create(@javax.annotation.Nonnull final Map<CharSequence, Object>... rows) { @javax.annotation.Nonnull final TableOutput table = new TableOutput(); Arrays.stream(rows).forEach(table::putRow); return table; }
/** * Calc number stats table output. * * @return the table output */ @javax.annotation.Nonnull public TableOutput calcNumberStats() { @javax.annotation.Nonnull final TableOutput tableOutput = new TableOutput(); schema.entrySet().stream().filter(x -> Number.class.isAssignableFrom(x.getValue())).map(col -> { final CharSequence key = col.getKey(); final DoubleStatistics stats = rows.stream().filter(x -> x.containsKey(key)).map(x -> (Number) x.get(key)).collect(DoubleStatistics.NUMBERS); @javax.annotation.Nonnull final LinkedHashMap<CharSequence, Object> row = new LinkedHashMap<>(); row.put("field", key); row.put("sum", stats.getSum()); row.put("avg", stats.getAverage()); row.put("stddev", stats.getStandardDeviation()); row.put("nulls", rows.size() - stats.getCount()); return row; }).sorted(Comparator.comparing(x -> x.get("field").toString())) .forEach(row -> tableOutput.putRow(row)); return tableOutput; }
/** * To html table string. * * @return the string */ public String toHtmlTable() { return toHtmlTable(false); }
TableOutput results = new TableOutput(); try { if (smallLayer instanceof DAGNetwork) { throw new RuntimeException(e); } finally { results.putRow(testResultProps); test.freeRef(); for (@Nonnull Tensor tensor : randomize) { log.out(results.toMarkdownTable());
throw new RuntimeException(e); } finally { results.putRow(testResultProps); for (@Nonnull Tensor t : input) { t.freeRef();
try (@javax.annotation.Nonnull FileOutputStream file = new FileOutputStream(new File(path, "data.tsv"))) { try (@javax.annotation.Nonnull PrintStream printStream = new PrintStream(file)) { printStream.println(toMarkdownTable());
TableOutput results = new TableOutput(); try { if (smallLayer instanceof DAGNetwork) { throw new RuntimeException(e); } finally { results.putRow(testResultProps); test.freeRef(); for (@Nonnull Tensor tensor : randomize) { log.out(results.toMarkdownTable());
private void tests(final NotebookOutput log, final List<ComponentTest<?>> tests, @Nonnull final Invocation invocation, @Nonnull final ArrayList<TestError> exceptions, TableOutput results) { tests.stream().filter(x -> null != x).forEach((ComponentTest<?> test) -> { @Nonnull Layer layer = invocation.getLayer().copy(); layer.addRef(); Tensor[] inputs = randomize(invocation.getDims()); LinkedHashMap<CharSequence, Object> testResultProps = new LinkedHashMap<>(); try { String testname = test.getClass().getCanonicalName(); testResultProps.put("class", testname); Object result = log.subreport(testname, sublog->test.test(sublog, layer, inputs)); testResultProps.put("details", null==result?null:result.toString()); testResultProps.put("result", "OK"); } catch (LifecycleException e) { throw e; } catch (Throwable e) { testResultProps.put("result", e.toString()); exceptions.add(new TestError(e, test, layer)); } finally { results.putRow(testResultProps); for (@Nonnull Tensor tensor : inputs) tensor.freeRef(); layer.freeRef(); test.freeRef(); System.gc(); } }); }
try (@javax.annotation.Nonnull FileOutputStream file = new FileOutputStream(new File(path, "data.tsv"))) { try (@javax.annotation.Nonnull PrintStream printStream = new PrintStream(file)) { printStream.println(toMarkdownTable());
/** * Create table output. * * @param rows the rows * @return the table output */ @javax.annotation.Nonnull public static TableOutput create(@javax.annotation.Nonnull final Map<CharSequence, Object>... rows) { @javax.annotation.Nonnull final TableOutput table = new TableOutput(); Arrays.stream(rows).forEach(table::putRow); return table; }
/** * Calc number stats table output. * * @return the table output */ @javax.annotation.Nonnull public TableOutput calcNumberStats() { @javax.annotation.Nonnull final TableOutput tableOutput = new TableOutput(); schema.entrySet().stream().filter(x -> Number.class.isAssignableFrom(x.getValue())).map(col -> { final CharSequence key = col.getKey(); final DoubleStatistics stats = rows.stream().filter(x -> x.containsKey(key)).map(x -> (Number) x.get(key)).collect(DoubleStatistics.NUMBERS); @javax.annotation.Nonnull final LinkedHashMap<CharSequence, Object> row = new LinkedHashMap<>(); row.put("field", key); row.put("sum", stats.getSum()); row.put("avg", stats.getAverage()); row.put("stddev", stats.getStandardDeviation()); row.put("nulls", rows.size() - stats.getCount()); return row; }).sorted(Comparator.comparing(x -> x.get("field").toString())) .forEach(row -> tableOutput.putRow(row)); return tableOutput; }
private void tests(final NotebookOutput log, final List<ComponentTest<?>> tests, @Nonnull final Invocation invocation, @Nonnull final ArrayList<TestError> exceptions, TableOutput results) { tests.stream().filter(x -> null != x).forEach((ComponentTest<?> test) -> { @Nonnull Layer layer = invocation.getLayer().copy(); layer.addRef(); Tensor[] inputs = randomize(invocation.getDims()); LinkedHashMap<CharSequence, Object> testResultProps = new LinkedHashMap<>(); try { String testname = test.getClass().getCanonicalName(); testResultProps.put("class", testname); Object result = log.subreport(testname, sublog->test.test(sublog, layer, inputs)); testResultProps.put("details", null==result?null:result.toString()); testResultProps.put("result", "OK"); } catch (LifecycleException e) { throw e; } catch (Throwable e) { testResultProps.put("result", e.toString()); exceptions.add(new TestError(e, test, layer)); } finally { results.putRow(testResultProps); for (@Nonnull Tensor tensor : inputs) tensor.freeRef(); layer.freeRef(); test.freeRef(); System.gc(); } }); }
escape = false; } else if (eval instanceof TableOutput) { str = ((TableOutput) eval).toMarkdownTable(); escape = false; } else {
/** * To html table string. * * @return the string */ public String toHtmlTable() { return toHtmlTable(false); }
log.eval(() -> { try { @Nonnull final TableOutput table = new TableOutput(); Lists.partition(data.validationData().collect(Collectors.toList()), 100).stream().flatMap(batch -> { @Nonnull TensorList batchIn = TensorArray.create(batch.stream().map(x -> x.data).toArray(i -> new Tensor[i]));
throw new RuntimeException(e); } finally { results.putRow(testResultProps); for (@Nonnull Tensor t : input) { t.freeRef();
escape = false; } else if (eval instanceof TableOutput) { str = ((TableOutput) eval).toMarkdownTable(); escape = false; } else {
log.eval(() -> { try { @Nonnull final TableOutput table = new TableOutput(); Lists.partition(data.validationData().collect(Collectors.toList()), 100).stream().flatMap(batch -> { @Nonnull TensorList batchIn = TensorArray.create(batch.stream().map(x -> x.data).toArray(i -> new Tensor[i]));
log.eval(() -> { try { @Nonnull final TableOutput table = new TableOutput(); Lists.partition(data.validationData().collect(Collectors.toList()), 100).stream().flatMap(batch -> { @Nonnull TensorList batchIn = TensorArray.create(batch.stream().map(x -> x.data).toArray(i -> new Tensor[i]));
testNetwork.add(imageNetwork, testNetwork.getInput(0)); log.eval(() -> { @Nonnull final TableOutput table = new TableOutput(); Arrays.stream(trainingData).map(tensorArray -> { @Nullable final Tensor predictionSignal = testNetwork.eval(tensorArray).getData().get(0);