在这种情况下,它创建了约30000个沉没器类实例,是否有某些原因?沉降片的平行度为16。
代码为:
def initialize_uninitialized_variables(sess):
with tf.name_scope('initialize_uninits'):
uninit_vars = []
uninit_tensors = []
for var in tf.global_variables():
uninit_vars.append(var)
uninit_tensors.append(tf.is_variable_initialized(var))
uninit_bools = sess.run(uninit_tensors)
uninit = zip(uninit_bools, uninit_vars)
uninit = [var for init, var in uninit if not init]
init_op = tf.variables_initializer(uninit)
sess.run(init_op)