TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

array_ops.gather raises exception

Open NiklasGustafsson opened this issue 5 years ago • 0 comments

While the following works in python:

input = tf.constant(np.arange(12.0).reshape(3,4))
indices = tf.constant([0,2])
ops.array_ops.gather(input,indices)

The corresponding code blows up with an exception in .NET:

var input =...;
var indices = ...;
var gather = array_ops.gather(input_array, indices);

The problem is in OpDefLibrary._apply_op_helper(), where on line 156, convert_to_tensor is called, which throws an exception on line 135 because it's given an eager tensor, in graph mode, outside of a function graph. I've been trying to find differences between the .NET implementation and the Python one, but I don't see where the problem lies.

This is also preventing the Embedding layer in Keras from working, since it calls gather.

NiklasGustafsson avatar Mar 09 '21 20:03 NiklasGustafsson