java - 如何在 Java (Eclipse) 文件中保存/显示神经网络的图形表示?

标签 java eclipse graph

我已经使用 Neuroph API 在 Java 中构建了一个神经网络。 API 中有一个名为 GraphmlExport 的包。我遵循了这个教程: http://fernando.carrillo.at/neuroph-graphml-export/

我将三行代码放入我的类中:

GraphmlExport ge = new GraphmlExport(myMLPerceptron);
        ge.parse();
        ge.writeToFile("/FILE/PATH/OUT");
        ge.printToStdout();

我不明白 writeToFile 的括号里需要写什么。 我使用 ge.printToStdout() 来查看它是否有效,它确实有效,但使用它是在控制台中像这样打印它:

graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key id="d1" for="edge" attr.name="weight" attr.type="double"></key>
<graph id="defaultId" edgedefault="directed">
    <node id="Input-0"></node>
    <edge source="Input-0" target="L1-0">
        <data key="d1">-1.5324200758107742</data>
        </edge>
    <edge source="Input-0" target="L1-1">
        <data key="d1">-6.718888335977713</data>
        </edge>

我需要更改什么才能使其实际正确显示?

最佳答案

我认为这不需要预先创建文件。 我对这个库不熟悉,但常见的做法是您提供一个文件路径,如果该文件不存在,则库将创建它。不过目录应该存在。

写入的内容是 XML,所以我会给它加上 .xml 扩展名。

鉴于您使用的是 Windows10 并假设您的 Windows 用户名是 ProddoBaggins,请尝试这样做

ge.writeToFile("C:\\Users\\ProddoBaggins\\exportFile.xml");

然后使用文件管理器查找文件 C:\Users\ProddoBaggins\exportFile.xml,它应该在那里。

我还假设,如果您给出的文件名已经存在,它将被覆盖。

编辑:我查了一下,似乎有一个 .graphml 扩展名,所以你应该使用它。即

ge.writeToFile("C:\\Users\\ProddoBaggins\\exportFile.graphml");

编辑:关于可视化,已经有一篇关于该主题的帖子 here

关于java - 如何在 Java (Eclipse) 文件中保存/显示神经网络的图形表示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47694089/

相关文章:

java - 使用 foreach 添加重复的字符串键以进行映射,其中值是重复次数

最小化顶点距离的算法 - Dwarf Fortress

用于计算大量文档(例如圣经书籍)相似度的算法

Java 游戏随机 id 数组

javac:包 org.apache.derby.client.am 不存在

android - SharedPreferences.Editor putString 和 putInt 错误

sql - 无法在 Eclipse 中引用 jdbc.SQLServerDriver (ClassNotFoundException)

eclipse - 如何设置gdb调试器连接?

algorithm - 寻找长路径

java - 安卓蓝牙配对: How to make sure to get bluetooth pairing request in the front dialog instead of a notification?