contrib.framework.filter_variables

tf.contrib.framework.filter_variables

tf.contrib.framework.filter_variables

filter_variables(
    var_list,
    include_patterns=None,
    exclude_patterns=None,
    reg_search=True
)

Defined in tensorflow/contrib/framework/python/ops/variables.py.

See the guide: Framework (contrib) > Variables

Filter a list of variables using regular expressions.

First includes variables according to the list of include_patterns. Afterwards, eliminates variables according to the list of exclude_patterns.

For example, one can obtain a list of variables with the weights of all convolutional layers (depending on the network definition) by:

variables = tf.contrib.framework.get_model_variables()
conv_weight_variables = tf.contrib.framework.filter_variables(
    variables,
    include_patterns=['Conv'],
    exclude_patterns=['biases', 'Logits'])

Args:

  • var_list: list of variables.
  • include_patterns: list of regular expressions to include. Defaults to None, which means all variables are selected according to the include rules. A variable is included if it matches any of the include_patterns.
  • exclude_patterns: list of regular expressions to exclude. Defaults to None, which means all variables are selected according to the exclude rules. A variable is excluded if it matches any of the exclude_patterns.
  • reg_search: boolean. If True (default), performs re.search to find matches (i.e. pattern can match any substring of the variable name). If False, performs re.match (i.e. regexp should match from the beginning of the variable name).

Returns:

filtered list of variables.

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/contrib/framework/filter_variables

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部