define inference method for get the result of forward-prob. the parameters delivered are simple
for more complicated models, the parameters should be managed by more efficient way
mechanism:construct and acquire the variables by their names
two methods
- tf.get_variable(value,shape,name)
- tf.variable_scope()
with tf.variable_scope(namespace,reuse=)
v=tf.get_variable(name,shape)
persistence
object: tf.train.Saver()
object.save(sess,path_/model.ckpt)
generate three files,which include the graphic data and structure data
loading method
- saver=tf.train.Saver()
- saver=tf.train.import_meta_graph(path/model.ckpt/model.ckpt.meta)
then you can obtain the graphic operation by the name of tensor like that
sess.run(tf.get_default_graph().get_tensor_by_name(tensor_name))
- saver=tf.train.Saver([variable_name]) ,loading part of the variables
- saver=tf.train.Saver({name:newname})
for that we can get the moving average by the dictionary mapping,like that
saver=tf.train.Saver({'v/ExponentialMovingAverage':v})
- saver=tf.train.Saver(ema.variable_to_restore())
presistence principles and data form
- MetaGraphDef
网友评论