I don't mind if it's YAML, JSON, .ini, or whatever.
The user should be able to change the reduction value in the call to the tf.keras.losses.CategoricalHinge function via a configuration file like below:
import tensorflow as tf
# config file reading happens here (expected scenario):
f = read_the_config_file()
reduction = f["reduction"] # retrieved the reduction value
# pass `reduction` to the loss function:
loss = tf.keras.losses(reduction)
reduction could either be tf.keras.losses.Reduction.NONE or tf.keras.losses.Reduction.AUTO. These values are tensorflow objects.
An example JSON file I'd expect will be like:
{
"reduction ": tf.keras.losses.Reduction.NONE
}
But obviously, this is an invalid JSON file.
Question:
Are there ways to let user pass this kind of a parameter in a config file? If not, what are the other ways of getting a such user input without keeping a string to object mapping in the user code?