tensorflow 2.X java,用于从org.tensorflow.example.example创建tensor的新api

2024-09-30 02:24:32 发布

您现在位置:Python中文网/ 问答频道 /正文

在tensorflow 1.x中 我们可以通过

Example example = buildExample(attributeVector);

byte[][] featureArray = new byte[1][]; 
featureArray[0] = example.toByteArray();

Tensor tensor = Tensor.create(featureArray);

在tf2.x java中删除了tensor.create()。 如何在java tf2.x中创建上述张量? 我试过这个:

Example example = buildExample(attributeVector);

byte[][] featureArray = new byte[1][];
featureArray[0] = example.toByteArray();
LOGGER.info("feautre array: " + featureArray);

Tensor tensor = TString.tensorOfBytes(NdArrays.scalarOfObject(featureArray));

错误是:

no instance(s) of type variable(s) exist so that byte[][] conforms to byte[] inference variable T has incompatible bounds: equality constraints: byte[] lower bounds: byte[][]


Tags: newexamplecreatejavabytevariabletensorbounds

热门问题