Skip to content

Instantly share code, notes, and snippets.

@gaphex
Last active November 25, 2019 18:06
Show Gist options
  • Save gaphex/e748ffde6627cb50aefea79322130d95 to your computer and use it in GitHub Desktop.
Save gaphex/e748ffde6627cb50aefea79322130d95 to your computer and use it in GitHub Desktop.
initialize_module method
def initialize_module(self):
sess = tf.keras.backend.get_session()
vars_initialized = sess.run([tf.is_variable_initialized(var)
for var in self.bert.variables])
uninitialized = []
for var, is_initialized in zip(self.bert.variables, vars_initialized):
if not is_initialized:
uninitialized.append(var)
if len(uninitialized):
sess.run(tf.variables_initializer(uninitialized))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment