目前AI已经火热的不行,这两天看了看TensorFlow,官方对TensorFlow的叙述以下:windows
TensorFlow是一个使用数据流图进行数值计算的开放源代码软件库。图中的节点表明数学运算,而图中的边则表明在这些节点之间传递的多维数组(张量)。借助这种灵活的架构,您能够经过一个 API 将计算工做部署到桌面设备、服务器或移动设备中的一个或多个 CPU 或 GPU。api
官网的环境中并无说明咱们在eclipse+JDK的环境怎么搭建TensorFlow的环境,本身尝试了一下仍是比较容易的bash
public class HelloTF {
public static void main(String[] args) throws Exception {
try (Graph g = new Graph()) {
final String value = "Hello from " + TensorFlow.version();
// Construct the computation graph with a single operation, a constant
// named "MyConst" with a value "value".
try (Tensor t = Tensor.create(value.getBytes("UTF-8"))) {
// The Java API doesn't yet include convenience functions for adding operations. g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build(); } // Execute the "MyConst" operation in a Session. try (Session s = new Session(g); Tensor output = s.runner().fetch("MyConst").run().get(0)) { System.out.println(new String(output.bytesValue(), "UTF-8")); } } } } 复制代码
Hello from 1.6.0
复制代码