当前位置: 首页>>代码示例>>Python>>正文


Python utils.get_variable_collections方法代码示例

本文整理汇总了Python中tensorflow.contrib.layers.python.layers.utils.get_variable_collections方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_variable_collections方法的具体用法?Python utils.get_variable_collections怎么用?Python utils.get_variable_collections使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.contrib.layers.python.layers.utils的用法示例。


在下文中一共展示了utils.get_variable_collections方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_variable_to_collections

# 需要导入模块: from tensorflow.contrib.layers.python.layers import utils [as 别名]
# 或者: from tensorflow.contrib.layers.python.layers.utils import get_variable_collections [as 别名]
def _add_variable_to_collections(variable, collections_set, collections_name):
  """Adds variable (or all its parts) to all collections with that name."""
  collections = utils.get_variable_collections(
      collections_set, collections_name) or []
  variables_list = [variable]
  if isinstance(variable, tf_variables.PartitionedVariable):
    variables_list = [v for v in variable]
  for collection in collections:
    for var in variables_list:
      if var not in ops.get_collection(collection):
        ops.add_to_collection(collection, var) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:layers.py

示例2: preact_conv2d

# 需要导入模块: from tensorflow.contrib.layers.python.layers import utils [as 别名]
# 或者: from tensorflow.contrib.layers.python.layers.utils import get_variable_collections [as 别名]
def preact_conv2d(
        inputs,
        num_outputs,
        kernel_size,
        stride=1,
        padding='SAME',
        activation_fn=nn.relu,
        normalizer_fn=None,
        normalizer_params=None,
        weights_initializer=initializers.xavier_initializer(),
        weights_regularizer=None,
        reuse=None,
        variables_collections=None,
        outputs_collections=None,
        trainable=True,
        scope=None):
    """Adds a 2D convolution preceded by batch normalization and activation.
    """
    with variable_scope.variable_scope(scope, 'Conv', values=[inputs], reuse=reuse) as sc:
        inputs = ops.convert_to_tensor(inputs)
        dtype = inputs.dtype.base_dtype
        if normalizer_fn:
            normalizer_params = normalizer_params or {}
            inputs = normalizer_fn(inputs, activation_fn=activation_fn, **normalizer_params)
        kernel_h, kernel_w = utils.two_element_tuple(kernel_size)
        stride_h, stride_w = utils.two_element_tuple(stride)
        num_filters_in = utils.last_dimension(inputs.get_shape(), min_rank=4)
        weights_shape = [kernel_h, kernel_w, num_filters_in, num_outputs]
        weights_collections = utils.get_variable_collections(variables_collections, 'weights')
        weights = variables.model_variable('weights',
                                           shape=weights_shape,
                                           dtype=dtype,
                                           initializer=weights_initializer,
                                           regularizer=weights_regularizer,
                                           collections=weights_collections,
                                           trainable=trainable)
        outputs = nn.conv2d(inputs, weights, [1, stride_h, stride_w, 1], padding=padding)
        return utils.collect_named_outputs(outputs_collections, sc.name, outputs) 
开发者ID:rwightman,项目名称:tensorflow-litterbox,代码行数:40,代码来源:preact_conv.py

示例3: _add_variable_to_collections

# 需要导入模块: from tensorflow.contrib.layers.python.layers import utils [as 别名]
# 或者: from tensorflow.contrib.layers.python.layers.utils import get_variable_collections [as 别名]
def _add_variable_to_collections(variable, collections_set, collections_name):
    """Adds variable (or all its parts) to all collections with that name."""
    collections = utils.get_variable_collections(
            collections_set, collections_name) or []
    variables_list = [variable]
    if isinstance(variable, tf_variables.PartitionedVariable):
        variables_list = [v for v in variable]
    for collection in collections:
        for var in variables_list:
            if var not in ops.get_collection(collection):
                ops.add_to_collection(collection, var) 
开发者ID:balancap,项目名称:tf-imagenet,代码行数:13,代码来源:convolution.py

示例4: _add_variable_to_collections

# 需要导入模块: from tensorflow.contrib.layers.python.layers import utils [as 别名]
# 或者: from tensorflow.contrib.layers.python.layers.utils import get_variable_collections [as 别名]
def _add_variable_to_collections(variable, collections_set, collections_name):
    """Adds variable (or all its parts) to all collections with that name."""
    collections = utils.get_variable_collections(collections_set,
                                                 collections_name) or []
    variables_list = [variable]
    if isinstance(variable, tf_variables.PartitionedVariable):
        variables_list = [v for v in variable]
    for collection in collections:
        for var in variables_list:
            if var not in ops.get_collection(collection):
                ops.add_to_collection(collection, var) 
开发者ID:hyperconnect,项目名称:MMNet,代码行数:13,代码来源:mmnet_utils.py


注:本文中的tensorflow.contrib.layers.python.layers.utils.get_variable_collections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。