Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clip to maximum / minimum finite int/float/double?

I'd like to clip some Tensorflow variables with tf.clip_by_value to the most positive / negative finite value possible. I'd like to reach a similar behavior like numpy.nan_to_num()

How do I get these values, given some data type? Does this clipping affect the optimizer?

like image 818
Hoeze Avatar asked Dec 08 '25 06:12

Hoeze


1 Answers

All TensorFlow datatypes have the min and max properties, that return the maximum and minimum values the type can hold. E.g.,

import tensorflow as tf

print( tf.float32.max )

Outputs:

3.4028235e+38

like image 104
Peter Szoldan Avatar answered Dec 10 '25 02:12

Peter Szoldan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!