Last active
November 25, 2019 18:06
-
-
Save gaphex/e748ffde6627cb50aefea79322130d95 to your computer and use it in GitHub Desktop.
initialize_module method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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