I'm trying to figure out how to extract sequential patches from a complex valued tensor where the length is variable. The extraction is being performed as part of a tf.data pipeline.
If the tensor were not complex, I'd use tf.image.extract_image_patches as in this answer.
However, that function does not work with complex tensors. I have tried the following technique, but it fails because the length of the tensor is unknown.
def extract_sequential_patches(image):
image_length = tf.shape(image)[0]
num_patches = image_length // (128 // 4)
patches = []
for i in range(num_patches):
start = i * 128
end = start + 128
patches.append(image[start:end, ...])
return tf.stack(patches)
However I get the error:
InaccessibleTensorError: The tensor 'Tensor("strided_slice:0", shape=(None, 512, 2), dtype=complex64)' cannot be accessed here: it is defined in another function or code block. Use return values, explicit Python locals or TensorFlow collections to access it. Defined in: FuncGraph(name=while_body_2100, id=140313967335120)
I have tried liberal decoration with @tf.function
from Tensorflow: extract sequential patches from a complex tensor of arbitrary length
No comments:
Post a Comment