keras
keras copied to clipboard
minval can be greater than maxval in tf.keras.initializers.RandomUniform
minval should be less than maxval. However, when minval is greater than maxval, the code works.
import tensorflow as tf
results={}
try:
minval = 10
maxval = -6
seed = 124
arg_class = tf.keras.initializers.RandomUniform(minval=minval,maxval=maxval,seed=seed,)
arg_input = [9,6,7,]
results["res"] = arg_class(arg_input)
except Exception as e:
results["err"] = "Error:"+str(e)
@cheyennee,
The output of the minval and maxval was working as expected in tf.keras.initializers.RandomUniform. Also we change the min and max values the output was different in both the cases. Kindly find the gist of it here.
@tilakrayal In other API, when minval is greater than maxval, it will throw an exception. I dont know why tf.keras.initializers.RandomUniform doesnt throw an exception, although it works as expected.
@cheyennee, Could you please provide the API doc link where it was mentioned that the exception was thrown. It helps to analyse the issue. Thank you!
@tilakrayal doc. In documentation, minval is the lower bound of the range of random values and maxval is the upper bound of the range of random values. So, I think the lower bound should be less than upper.
@gadagashwini, I was able to reproduce the issue on tensoflow v2.8, v2.9 and nightly. Kindly find the gist of it here.
@gadagashwini @cheyennee
Logically, yes it should throw an error. But i tried it multiple times and it initializes values in range [minval, maxval] or [maxval, minval] whichever holds.
I would be happy to send a PR, in case we think it is required.