Python nets.nasnet.nasnet_utils.calc_reduction_layers() Examples

The following are 29 code examples of nets.nasnet.nasnet_utils.calc_reduction_layers(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module nets.nasnet.nasnet_utils , or try the search function .
Example #1
Source File: nasnet_utils_test.py    From models with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #2
Source File: nasnet_utils_test.py    From nasnet-tensorflow with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #3
Source File: nasnet_utils_test.py    From MAX-Object-Detector with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #4
Source File: nasnet_utils_test.py    From SENet-tensorflow-slim with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #5
Source File: nasnet_utils_test.py    From object_detection_with_tensorflow with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #6
Source File: nasnet_utils_test.py    From g-tensorflow-models with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #7
Source File: nasnet_utils_test.py    From TwinGAN with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #8
Source File: nasnet_utils_test.py    From style_swap_tensorflow with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #9
Source File: nasnet_utils_test.py    From MAX-Image-Segmenter with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #10
Source File: nasnet_utils_test.py    From BMW-TensorFlow-Training-GUI with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #11
Source File: nasnet_utils_test.py    From Creative-Adversarial-Networks with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #12
Source File: nasnet_utils_test.py    From Gun-Detector with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #13
Source File: nasnet_utils_test.py    From CBAM-tensorflow-slim with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #14
Source File: nasnet_utils_test.py    From yolo_v2 with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #15
Source File: nasnet_utils_test.py    From edafa with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #16
Source File: nasnet_utils_test.py    From CVTron with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #17
Source File: nasnet_utils_test.py    From multilabel-image-classification-tensorflow with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #18
Source File: nasnet_utils_test.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #19
Source File: nasnet_utils_test.py    From DeepLab_v3 with MIT License 5 votes vote down vote up
def testCalcReductionLayers(self):
    num_cells = 18
    num_reduction_layers = 2
    reduction_layers = nasnet_utils.calc_reduction_layers(
        num_cells, num_reduction_layers)
    self.assertEqual(len(reduction_layers), 2)
    self.assertEqual(reduction_layers[0], 6)
    self.assertEqual(reduction_layers[1], 12) 
Example #20
Source File: faster_rcnn_pnas_feature_extractor.py    From multilabel-image-classification-tensorflow with MIT License 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #21
Source File: faster_rcnn_pnas_feature_extractor.py    From models with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #22
Source File: faster_rcnn_pnas_feature_extractor.py    From g-tensorflow-models with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #23
Source File: faster_rcnn_pnas_feature_extractor.py    From MAX-Object-Detector with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #24
Source File: faster_rcnn_pnas_feature_extractor.py    From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #25
Source File: faster_rcnn_pnas_feature_extractor.py    From BMW-TensorFlow-Training-GUI with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #26
Source File: faster_rcnn_pnas_feature_extractor.py    From ros_tensorflow with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #27
Source File: faster_rcnn_pnas_feature_extractor.py    From Gun-Detector with Apache License 2.0 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #28
Source File: faster_rcnn_pnas_feature_extractor.py    From Person-Detection-and-Tracking with MIT License 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time. 
Example #29
Source File: faster_rcnn_pnas_feature_extractor.py    From vehicle_counting_tensorflow with MIT License 4 votes vote down vote up
def _build_pnasnet_base(
    hidden_previous, hidden, normal_cell, hparams, true_cell_num,
    start_cell_num):
  """Constructs a PNASNet image model for proposal classifier features."""

  # Find where to place the reduction cells or stride normal cells
  reduction_indices = nasnet_utils.calc_reduction_layers(
      hparams.num_cells, hparams.num_reduction_layers)
  filter_scaling = _filter_scaling(reduction_indices, start_cell_num)

  # Note: The None is prepended to match the behavior of _imagenet_stem()
  cell_outputs = [None, hidden_previous, hidden]
  net = hidden

  # Run the cells
  for cell_num in range(start_cell_num, hparams.num_cells):
    is_reduction = cell_num in reduction_indices
    stride = 2 if is_reduction else 1
    if is_reduction: filter_scaling *= hparams.filter_scaling_rate
    prev_layer = cell_outputs[-2]
    net = normal_cell(
        net,
        scope='cell_{}'.format(cell_num),
        filter_scaling=filter_scaling,
        stride=stride,
        prev_layer=prev_layer,
        cell_num=true_cell_num)
    true_cell_num += 1
    cell_outputs.append(net)

  # Final nonlinearity.
  # Note that we have dropped the final pooling, dropout and softmax layers
  # from the default pnasnet version.
  with tf.variable_scope('final_layer'):
    net = tf.nn.relu(net)
  return net


# TODO(shlens): Only fixed_shape_resizer is currently supported for PNASNet
# featurization. The reason for this is that pnasnet.py only supports
# inputs with fully known shapes. We need to update pnasnet.py to handle
# shapes not known at compile time.