It'd be useful if tableprint could accept a custom print command. In my use case, I want to progressively (print-as-I-go) print the values of TensorFlow 2 tensors in a table.
In autograph, the only way to print TensorFlow tensors is with tf.print—using print(my_tensor) doesn't print the value.
I can think of two ways to approach this:
- accept a callable that defaults to Python's
print.
- The only problem is that there are certain options that tableprint may need to pass to
tf.print; for example, output_stream. Since these arguments differ from those of Python's print, tableprint's implementation will need to use if statements to see if the callable is tf.print. This brings me to the second option:
- accept a boolean called
print_tensorflow that defaults to False. If True, print using tf.print.
- I like this idea better since the first option implies that any callable can be used, such as
click.echo, even if tableprint doesn't have click.echo's options implemented (of course, a NotImplementedError could be raised).
- However, this would limit tableprint to only
print and tf.print. If you want to add more callables in the future, you could always change this argument to a string, and use an if statement to see if the string is python, tensorflow, click, etc.
It'd be useful if
tableprintcould accept a custom print command. In my use case, I want to progressively (print-as-I-go) print the values of TensorFlow 2 tensors in a table.In autograph, the only way to print TensorFlow tensors is with
tf.print—usingprint(my_tensor)doesn't print the value.I can think of two ways to approach this:
print.tf.print; for example,output_stream. Since these arguments differ from those of Python's print, tableprint's implementation will need to useifstatements to see if the callable istf.print. This brings me to the second option:print_tensorflowthat defaults toFalse. IfTrue, print usingtf.print.click.echo, even if tableprint doesn't haveclick.echo's options implemented (of course, aNotImplementedErrorcould be raised).printandtf.print. If you want to add more callables in the future, you could always change this argument to a string, and use anifstatement to see if the string ispython,tensorflow,click, etc.