Das hier is von einem anderen Thema abgetrennt, in dem es ursprünglich nur um einen Rant gegen Protocol Buffers ging - das Thema TensorFlow könnte aber von allgemeinerem Interesse sein
Tensorflow an sich aus Java zu verwenden ist mit/dank Maven erfrischend trivial: Dependency rein und los geht’s.
Um rauszufinden, was so eine Zeile wie
g.opBuilder("Const", "MyConst").setAttr("dtype", t.dataType()).setAttr("value", t).build();
macht, reicht die JavaDoc aber nicht: Ist „Const“ einfach ein Name oder ein „reservierter Bezeichner“? Welche „attr“'s gibt es? Hier offenbar „dtype“ und „value“. Gibt es die immer? Welche gibt es noch? Welche Werte dürfen/müssen die haben? Das geht aus der oben verlinkten Datei hervor:
name: "Const"
output_arg {
name: "output"
type_attr: "dtype"
}
attr {
name: "value"
type: "tensor"
description: "Attr `value` is the tensor to return."
}
attr {
name: "dtype"
type: "type"
}
summary: "Returns a constant tensor."
Bisher macht mein Generator aus diesen Dingern jetzt nur sowas wie
/**
* Gradient op for <code>MirrorPad</code> op. This op folds a mirror-padded tensor.<p>This operation folds the padded areas of <code>input</code> by <code>MirrorPad</code> according to the
* <code>paddings</code> you specify. <code>paddings</code> must be the same as <code>paddings</code> argument
* given to the corresponding <code>MirrorPad</code> op.</p>
* <p>The folded size of each dimension D of the output is:</p>
* <p><code>input.dim_size(D) - paddings(D, 0) - paddings(D, 1)</code></p>
* <p>For example:</p>
* <pre><code># 't' is [[1, 2, 3], [4, 5, 6], [7, 8, 9]].
* # 'paddings' is [[0, 1]], [0, 1]].
* # 'mode' is SYMMETRIC.
* # rank of 't' is 2.
* pad(t, paddings) ==> [[ 1, 5]
* [11, 28]]
* </code></pre>
*
* @param input
* The input tensor to be folded.
* @param paddings
* A two-column matrix specifying the padding sizes. The number of
* rows must be the same as the rank of <code>input</code>.
*/
public<T >Output<T> mirrorPadGrad(Output<T> input, Output<T> paddings) {
return null;
}
(also ziemlich leer…). Mal schauen, ob da was vernünftiges rauskommen kann…