Speaking of machine learning, TensorFlow developed by Google is famous.
In fact, you can use TensorFlow even with Java, which everyone loves. Moreover, it is very easy to use. Just add one library to your build.
compile 'org.tensorflow:tensorflow:1.7.0'
The whole build.gradle is here
This alone will make the sample code work.
Sample excerpt
try (Graph g = new Graph(); Session session = new Session(g)) {
Tensor<?> t = Tensor.create("First TensorFlow".getBytes());
g.opBuilder("Const", "message").setAttr("dtype", t.dataType()).setAttr("value", t).build();
Tensor<?> out = session.runner().fetch("message").run().get(0);
System.out.println(new String(out.bytesValue()));
}
↓ Output to TensorFlow and console for the first time.
The entire sample code is here
It's very easy to set up a machine learning environment.
Judgment can be done in Java, but the first learning needs to be done elsewhere, such as Python or C. I hope I can do it in Java from the beginning!
Recommended Posts