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


Python tensorflow.concats方法代码示例

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


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

示例1: AddParallel

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import concats [as 别名]
def AddParallel(self, prev_layer, index):
    """tf.concats outputs of layers that run on the same inputs.

    Args:
      prev_layer: Input tensor.
      index:      Position in model_str to start parsing

    Returns:
      Output tensor of the parallel,  end index in model_str.

    Raises:
      ValueError: If () are unbalanced or the elements don't match.
    """
    if self.model_str[index] != '(':
      return None, None
    index += 1
    layers = []
    num_dims = 0
    # Each parallel must output the same, including any reduction factor, in
    # all dimensions except depth.
    # We have to save the starting factors, so they don't get reduced by all
    # the elements of the parallel, only once.
    original_factors = self.reduction_factors
    final_factors = None
    while index < len(self.model_str) and self.model_str[index] != ')':
      self.reduction_factors = original_factors
      layer, index = self.BuildFromString(prev_layer, index)
      if num_dims == 0:
        num_dims = len(layer.get_shape())
      elif num_dims != len(layer.get_shape()):
        raise ValueError('All elements of parallel must return same num dims')
      layers.append(layer)
      if final_factors:
        if final_factors != self.reduction_factors:
          raise ValueError('All elements of parallel must scale the same')
      else:
        final_factors = self.reduction_factors
    if index == len(self.model_str):
      raise ValueError('Missing ) at end of parallel!' + self.model_str)
    return tf.concat(axis=num_dims - 1, values=layers), index + 1 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:42,代码来源:vgslspecs.py

示例2: AddParallel

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import concats [as 别名]
def AddParallel(self, prev_layer, index, reuse=None):
        """tf.concats outputs of layers that run on the same inputs.
    
        Args:
          prev_layer: Input tensor.
          index:      Position in model_str to start parsing
    
        Returns:
          Output tensor of the parallel,  end index in model_str.
    
        Raises:
          ValueError: If () are unbalanced or the elements don't match.
        """
        if self.model_str[index] != '(':
            return None, None
        index += 1
        layers = []
        num_dims = 0
        # Each parallel must output the same, including any reduction factor, in
        # all dimensions except depth.
        # We have to save the starting factors, so they don't get reduced by all
        # the elements of the parallel, only once.
        original_factors = self.reduction_factors
        final_factors = None
        while index < len(self.model_str) and self.model_str[index] != ')':
            self.reduction_factors = original_factors
            layer, index = self.BuildFromString(prev_layer, index)
            if num_dims == 0:
                num_dims = len(layer.get_shape())
            elif num_dims != len(layer.get_shape()):
                raise ValueError('All elements of parallel must return same num dims')
            layers.append(layer)
            if final_factors:
                if final_factors != self.reduction_factors:
                    raise ValueError('All elements of parallel must scale the same')
            else:
                final_factors = self.reduction_factors
        if index == len(self.model_str):
            raise ValueError('Missing ) at end of parallel!' + self.model_str)
        return tf.concat(axis=num_dims - 1, values=layers), index + 1 
开发者ID:ftramer,项目名称:ad-versarial,代码行数:42,代码来源:vgslspecs.py

示例3: AddParallel

# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import concats [as 别名]
def AddParallel(self, prev_layer, index):
    """tf.concats outputs of layers that run on the same inputs.

    Args:
      prev_layer: Input tensor.
      index:      Position in model_str to start parsing

    Returns:
      Output tensor of the parallel,  end index in model_str.

    Raises:
      ValueError: If () are unbalanced or the elements don't match.
    """
    if self.model_str[index] != '(':
      return None, None
    index += 1
    layers = []
    num_dims = 0
    # Each parallel must output the same, including any reduction factor, in
    # all dimensions except depth.
    # We have to save the starting factors, so they don't get reduced by all
    # the elements of the parallel, only once.
    original_factors = self.reduction_factors
    final_factors = None
    while index < len(self.model_str) and self.model_str[index] != ')':
      self.reduction_factors = original_factors
      layer, index = self.BuildFromString(prev_layer, index)
      if num_dims == 0:
        num_dims = len(layer.get_shape())
      elif num_dims != len(layer.get_shape()):
        raise ValueError('All elements of parallel must return same num dims')
      layers.append(layer)
      if final_factors:
        if final_factors != self.reduction_factors:
          raise ValueError('All elements of parallel must scale the same')
      else:
        final_factors = self.reduction_factors
    if index == len(self.model_str):
      raise ValueError('Missing ) at end of parallel!' + self.model_str)
    return tf.concat(num_dims - 1, layers), index + 1 
开发者ID:coderSkyChen,项目名称:Action_Recognition_Zoo,代码行数:42,代码来源:vgslspecs.py


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