def get_variables(prefix=None):
"""Get variables by their name prefix.
Arguments:
prefix: a `str` or a `tf.VariableScope` instance.
Returns:
a list of `tf.Variable` with their name starting with the
given prefix, i.e. all those variables under the scope
specified by the prefix.
"""
prefix = prefix or tf.get_variable_scope().name
return [var for var in tf.global_variables()
if var.name.startswith(prefix)]
评论列表
文章目录