ashpy icon indicating copy to clipboard operation
ashpy copied to clipboard

[FEATURE] - Add a flag for correct scaling of logged TensorBoard images

Open mr-ubik opened this issue 4 years ago • 4 comments

System information

  • AshPy version (you are using): 0.4.0
  • Are you willing to contribute it (Yes/No): Yes

Describe the feature and the current behavior/state TensorBoard images should be logged in the [0, 1] range when float. Currently, we do not provide any type of automatic handling of this scaling, so if you are training on [-1, 1] and using our callbacks, images will be logged without scaling.

Will this change the current API? How? Small change to ashpy.utils.log() and all the callbacks using it, they will now accept a new boolean argument auto_tb_scaling controlling this behavior.

Who will benefit with this feature? Anyone using the default logging facilities.

Any Other info

mr-ubik avatar Apr 07 '20 09:04 mr-ubik

Do you think that a boolean flag is enough?

If the input is float tensorboard wants the range [0,1] so we need to scale the image if the range is [-1, 1] or if the range is [0, 255] (Are there people using the range [0, 255] and float dtype?).

In this case we can accept an enum describing the input range.

EmanueleGhelfi avatar Apr 07 '20 10:04 EmanueleGhelfi

Yeah, an Enum is probably better.

mr-ubik avatar Apr 07 '20 17:04 mr-ubik

I guess we should go with this approach:

  1. If the image dtype is tf.uin8, then we expect values on [0-255] (follow the tensorflow convention)
  2. If the image dytpe is tf.float* then the image should be in the range [0.1] (tensorflow convention). We can support only the most common scenario that's an image with values squashed in [-1,1]. Thus a boolean for this case is enough IMHO
  3. Else raise error

galeone avatar Apr 08 '20 08:04 galeone

Initial implementation in #56

See https://github.com/zurutech/ashpy/pull/56/commits/18f9e41d7bc639b1db868e1fcbaa302bfa2616ec#diff-b3393cc30d90b7f5a9c26ecc968ef758R44

EmanueleGhelfi avatar Apr 08 '20 12:04 EmanueleGhelfi