Hi,
I am currently trying to create the following function:
Args:
- starts: A tensor of shape (batch, N) where N ist the dimensionality of the target grid. specifying the smallest value for the grid in each dimension
- stops: A tensor of shape (batch, N) where N ist the dimensionality of the target grid. specifying the largest value for the grid in each dimension
- nums: A list of the number of steps of the target grid for each dimension of the shape (N)
Returns: A tensor of shape (batch, nums[0],nums[1],…nums[N-1],N) being a evenly-spaced grid of dimension N with each dimension k going ranging from starts[b,k] to stops[b,k] in nums[k] steps in batch b.
This is pretty similar to tfg.geometry.representation.grid.generate | TensorFlow Graphics
However this function does not play well with the batch size not being specified and in the docs it says it is not differentiable:
startsInput=tf.keras.Input(shape=(2,))
stopsInput=tf.keras.Input(shape=(2,))
tfg.geometry.representation.grid.generate(starts=startsInput, stops=stopsInput, nums=[3, 3])
This call fails since the method calls tf.unstack(starts), but the first dimension of starts is “None” since the batch size in unknown at this time. However the call with real data works as expected:
tfg.geometry.representation.grid.generate(starts=[[1.0, 1.0]], stops=[[2.0, 2.0]], nums=[3, 3])
Is there a way to create such a method that works with undefined batch sizes and is differentiable?