1

I am using a trained Tensorflow model in Java on Android. I am trying to extract the output of an intermediary op.

The Tensor I am extracting has shape (150, 150, 256).

I have declared the output target to be

private float[] hybridValues;
hybridValues = new float[150 * 150 * 256];

I am then getting the output using.

inferenceInterface.fetch(OUTPUT_NODE, hybridValues);

The values are fine but they are stored as a 1D array. Is there a way to get inferenceinterface.fetch to return a multi-dimentional array?

I tried declaring hybridValue to be a three dimensional float array but that doesn't work as the fetch method expects a 1D array.

The end goal is to pass my output to a Python program that will feed the values to a Tensor of the same shape (150, 150, 256).

For comparison the Python a_output = graph.get_tensor_by_name('a2b_generator/Conv_7/Relu:0') returns an ndarray with values in the same shape as the target tensor.

Andrew
  • 183
  • 1
  • 8

1 Answers1

0

I'm using tensorflow with java on the desktop (which might be different) and all I do is create a multi-dimensional array with the correct size, then copy the values over, e.g. Tensor.copyTo(Object dst)

geometrikal
  • 3,195
  • 2
  • 29
  • 40