tensorflowtensorflow-datasetstensorflow-estimator

How to feed tensors of variable shapes to tf estimator


I am interested in studying graphs in tensorflow. The number of nodes varies from graph to graph in my dataset. This is problematic because, in my observation, tensorflow does not easily allow me to input data with variable shapes.

More specifically, could anyone suggest an easy way to feed batches of 2d arrays to a tf.Estimator.estimator , when the shapes of arrays are different? I have been using tf.estimator.inputs.numpy_input_fn for a dataset with fixed sizes, but I now need a different approach.


Solution

  • Ragged tensor has been introduced for this purpose.

    https://www.tensorflow.org/guide/ragged_tensor