目前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
複製代碼