MCPcopy
hub / github.com/GPflow/GPflow / to_default_float

Function to_default_float

gpflow/utilities/misc.py:47–54  ·  view source on GitHub ↗
(x: TensorData)

Source from the content-addressed store, hash-verified

45 "return: [any...]",
46)
47def to_default_float(x: TensorData) -> tf.Tensor:
48 if not tf.is_tensor(x):
49 # workaround for the fact that tf.cast(, dtype=tf.float64) doesn't directly convert
50 # python floats to tf.float64 tensors. Instead, it converts the python float to a
51 # tf.float32 tensor, and then casts that to be tf.float64. This results in a loss
52 # of precision. See https://github.com/tensorflow/tensorflow/issues/57779 for more context.
53 return tf.convert_to_tensor(x, default_float())
54 return tf.cast(x, dtype=default_float())
55
56
57def set_trainable(model: Union[tf.Module, Iterable[tf.Module]], flag: bool) -> None:

Callers 15

__init__Method · 0.90
test_to_default_floatFunction · 0.90
build_modelFunction · 0.90
test_sgpr_quFunction · 0.90
DatumClass · 0.90
map_fnFunction · 0.90
gauss_kl_vffFunction · 0.90
gauss_klFunction · 0.85

Calls 1

default_floatFunction · 0.85

Tested by 6

__init__Method · 0.72
test_to_default_floatFunction · 0.72
build_modelFunction · 0.72
test_sgpr_quFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…