python - In TensorFlow is there any way to just initialize uninitialised variables? -


the standard way of initializing variables in tensorflow is

init = tf.initialize_all_variables() sess = tf.session() sess.run(init) 

after running learning while create new set of variables once initialize them resets existing variables. @ moment way around save variable need , reapply them after tf.initalize_all_variables call. works bit ugly , clunky. cannot find in docs...

does know of way initialize uninitialized variables?

there no elegant* way enumerate uninitialized variables in graph. however, if have access new variable objects—let's call them v_6, v_7, , v_8—you can selectively initialize them using tf.initialize_variables():

init_new_vars_op = tf.initialize_variables([v_6, v_7, v_8]) sess.run(init_new_vars_op) 

* a process of trial , error used identify uninitialized variables, follows:

uninitialized_vars = [] var in tf.all_variables():     try:         sess.run(var)     except tf.errors.failedpreconditionerror:         uninitialized_vars.append(var)  init_new_vars_op = tf.initialize_variables(uninitialized_vars) # ... 

...however, not condone such behavior :-).


Comments

Popular posts from this blog

shader - OpenGL Shadow Map -

stringtemplate - StringTemplate4 if conditional with length -