Skip to content

Instantly share code, notes, and snippets.

Last active February 25, 2019 12:33
What would you like to do?
Use custom getter
# source:
def float32_variable_storage_getter(getter, name, shape=None, dtype=None,
initializer=None, regularizer=None,
*args, **kwargs):
storage_dtype = tf.float32 if trainable else dtype
variable = getter(name, shape, dtype=storage_dtype,
initializer=initializer, regularizer=regularizer,
*args, **kwargs)
if trainable and dtype != tf.float32:
variable = tf.cast(variable, dtype)
return variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment