class_docstr: Instantiates the ResNet50 architecture.
  
  Args:
    data_format: format for the image. Either 'channels_first' or
      'channels_last'.  'channels_first' is typically faster on GPUs while
      'channels_last' is typically faster on CPUs. See
      https://www.tensorflow.org/performance/performance_guide#data_formats
    name: Prefix applied to names of variables created in the model.
    trainable: Is the model trainable? If true, performs backward
        and optimization after call() method.
    include_top: whether to include the fully-connected layer at the top of the
      network.
    pooling: Optional pooling mode for feature extraction when `include_top`
      is `False`.
      - `None` means that the output of the model will be the 4D tensor
          output of the last convolutional layer.
      - `avg` means that global average pooling will be applied to the output of
          the last convolutional layer, and thus the output of the model will be
          a 2D tensor.
      - `max` means that global max pooling will be applied.
    block3_strides: whether to add a stride of 2 to block3 to make it compatible
      with tf.slim ResNet implementation.
    average_pooling: whether to do average pooling of block4 features before
      global pooling.
    classes: optional number of classes to classify images into, only to be
      specified if `include_top` is True.
  
  Raises:
      ValueError: in case of invalid argument for data_format.
code: def __init__(
      self,
      data_format,
      name="",
      trainable=True,
      include_top=True,
      pooling=None,
      block3_strides=False,
      average_pooling=True,
      classes=1000,
  ):
      super(ResNet50, self).__init__(name=name)
  
      valid_channel_values = ("channels_first", "channels_last")
      if data_format not in valid_channel_values:
          raise ValueError(
              "Unknown data_format: %s. Valid values: %s"
              % (data_format, valid_channel_values)
          )
      self.include_top = include_top
      self.block3_strides = block3_strides
      self.average_pooling = average_pooling
      self.pooling = pooling
  
      def conv_block(filters, stage, block, strides=(2, 2)):
          return _ConvBlock(
              3,
              filters,
              stage=stage,
              block=block,
              data_format=data_format,
              strides=strides,
          )
  
      def id_block(filters, stage, block):
          return _IdentityBlock(
              3,
              filters,
              stage=stage,
              block=block,
              data_format=data_format,
          )
  
      self.conv1 = layers.Conv2D(
          64,
          (7, 7),
          strides=(2, 2),
          data_format=data_format,
          padding="same",
          name="conv1",
      )
      bn_axis = 1 if data_format == "channels_first" else 3
      self.bn_conv1 = layers.BatchNormalization(
          axis=bn_axis, name="bn_conv1"
      )
      self.max_pool = layers.MaxPooling2D(
          (3, 3), strides=(2, 2), data_format=data_format
      )
  
      self.l2a = conv_block(
          [64, 64, 256], stage=2, block="a", strides=(1, 1)
      )
      self.l2b = id_block([64, 64, 256], stage=2, block="b")
      self.l2c = id_block([64, 64, 256], stage=2, block="c")
  
      self.l3a = conv_block([128, 128, 512], stage=3, block="a")
      self.l3b = id_block([128, 128, 512], stage=3, block="b")
      self.l3c = id_block([128, 128, 512], stage=3, block="c")
      self.l3d = id_block([128, 128, 512], stage=3, block="d")
  
      self.l4a = conv_block([256, 256, 1024], stage=4, block="a")
      self.l4b = id_block([256, 256, 1024], stage=4, block="b")
      self.l4c = id_block([256, 256, 1024], stage=4, block="c")
      self.l4d = id_block([256, 256, 1024], stage=4, block="d")
      self.l4e = id_block([256, 256, 1024], stage=4, block="e")
      self.l4f = id_block([256, 256, 1024], stage=4, block="f")
  
      # Striding layer that can be used on top of block3 to produce feature maps
      # with the same resolution as the TF-Slim implementation.
      if self.block3_strides:
          self.subsampling_layer = layers.MaxPooling2D(
              (1, 1), strides=(2, 2), data_format=data_format
          )
          self.l5a = conv_block(
              [512, 512, 2048], stage=5, block="a", strides=(1, 1)
          )
      else:
          self.l5a = conv_block([512, 512, 2048], stage=5, block="a")
      self.l5b = id_block([512, 512, 2048], stage=5, block="b")
      self.l5c = id_block([512, 512, 2048], stage=5, block="c")
  
      self.avg_pool = layers.AveragePooling2D(
          (7, 7), strides=(7, 7), data_format=data_format
      )
  
      if self.include_top:
          self.flatten = layers.Flatten()
          self.fc1000 = layers.Dense(classes, name="fc1000")
      else:
          reduction_indices = (
              [1, 2] if data_format == "channels_last" else [2, 3]
          )
          reduction_indices = tf.constant(reduction_indices)
          if pooling == "avg":
              self.global_pooling = functools.partial(
                  tf.reduce_mean, axis=reduction_indices, keepdims=False
              )
          elif pooling == "max":
              self.global_pooling = functools.partial(
                  tf.reduce_max,
                  reduction_indices=reduction_indices,
                  keep_dims=False,
              )
          else:
              self.global_pooling = None
  
file_path: tensorflow-upstream/tensorflow/python/eager/benchmarks/resnet50/resnet50.py
imports: import functools
  import tensorflow
label_desc: Use image node_id 1 to create a new ResNet50 object from inherited base classes: tf.keras with example: obj = ResNet50(data_format, name, trainable, include_top, pooling, block3_strides, average_pooling, classes)