Java Code Examples for org.deeplearning4j.nn.conf.ComputationGraphConfiguration#getMemoryReport()

The following examples show how to use org.deeplearning4j.nn.conf.ComputationGraphConfiguration#getMemoryReport() . 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: TestMemoryReports.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testMemoryReportSimpleCG() {

    List<Pair<? extends Layer, InputType>> l = getTestLayers();


    for (Pair<? extends Layer, InputType> p : l) {

        ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().graphBuilder().addInputs("in")
                        .addLayer("0", p.getFirst().clone(), "in").addLayer("1", p.getFirst().clone(), "0")
                        .setOutputs("1").validateOutputLayerConfig(false).build();

        MemoryReport mr = conf.getMemoryReport(p.getSecond());
        //            System.out.println(mr.toString());
        //            System.out.println("\n\n");

        //Test to/from JSON + YAML
        String json = mr.toJson();
        String yaml = mr.toYaml();

        MemoryReport fromJson = MemoryReport.fromJson(json);
        MemoryReport fromYaml = MemoryReport.fromYaml(yaml);

        assertEquals(mr, fromJson);
        assertEquals(mr, fromYaml);
    }
}
 
Example 2
Source File: TestMemoryReports.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testMemoryReportsVerticesCG() {
    List<Pair<? extends GraphVertex, InputType[]>> l = getTestVertices();

    for (Pair<? extends GraphVertex, InputType[]> p : l) {
        List<String> inputs = new ArrayList<>();
        for (int i = 0; i < p.getSecond().length; i++) {
            inputs.add(String.valueOf(i));
        }

        String[] layerInputs = inputs.toArray(new String[inputs.size()]);
        if (p.getFirst() instanceof DuplicateToTimeSeriesVertex) {
            layerInputs = new String[] {"1"};
        }

        ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder().graphBuilder().addInputs(inputs)
                        .allowDisconnected(true)
                        .addVertex("gv", p.getFirst(), layerInputs).setOutputs("gv").build();

        MemoryReport mr = conf.getMemoryReport(p.getSecond());
        //            System.out.println(mr.toString());
        //            System.out.println("\n\n");

        //Test to/from JSON + YAML
        String json = mr.toJson();
        String yaml = mr.toYaml();

        MemoryReport fromJson = MemoryReport.fromJson(json);
        MemoryReport fromYaml = MemoryReport.fromYaml(yaml);

        assertEquals(mr, fromJson);
        assertEquals(mr, fromYaml);
    }
}
 
Example 3
Source File: TestMemoryReports.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Test
public void testPreprocessors() throws Exception {
    //https://github.com/deeplearning4j/deeplearning4j/issues/4223
    File f = new ClassPathResource("4223/CompGraphConfig.json").getTempFileFromArchive();
    String s = FileUtils.readFileToString(f, Charset.defaultCharset());

    ComputationGraphConfiguration conf = ComputationGraphConfiguration.fromJson(s);

    conf.getMemoryReport(InputType.convolutional(17,19,19));
}