當前位置: 首頁>>代碼示例>>Python>>正文


Python hyperparams_builder.KerasLayerHyperparams方法代碼示例

本文整理匯總了Python中object_detection.builders.hyperparams_builder.KerasLayerHyperparams方法的典型用法代碼示例。如果您正苦於以下問題:Python hyperparams_builder.KerasLayerHyperparams方法的具體用法?Python hyperparams_builder.KerasLayerHyperparams怎麽用?Python hyperparams_builder.KerasLayerHyperparams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在object_detection.builders.hyperparams_builder的用法示例。


在下文中一共展示了hyperparams_builder.KerasLayerHyperparams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _build_conv_hyperparams

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def _build_conv_hyperparams(self):
    conv_hyperparams = hyperparams_pb2.Hyperparams()
    conv_hyperparams_text_proto = """
      activation: RELU_6
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      batch_norm {
        scale: false
      }
    """
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams)
    return hyperparams_builder.KerasLayerHyperparams(conv_hyperparams) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:20,代碼來源:ssd_feature_extractor_test.py

示例2: _build_conv_hyperparams

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def _build_conv_hyperparams(self):
    conv_hyperparams = hyperparams_pb2.Hyperparams()
    conv_hyperparams_text_proto = """
      activation: RELU_6
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      batch_norm {
        train: true,
        scale: false,
        center: true,
        decay: 0.2,
        epsilon: 0.1,
      }
    """
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams)
    return hyperparams_builder.KerasLayerHyperparams(conv_hyperparams) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:mobilenet_v2_test.py

示例3: test_return_l1_regularized_weights_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_return_l1_regularized_weights_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l1_regularizer {
          weight: 0.5
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)

    regularizer = keras_config.params()['kernel_regularizer']
    weights = np.array([1., -1, 4., 2.])
    with self.test_session() as sess:
      result = sess.run(regularizer(tf.constant(weights)))
    self.assertAllClose(np.abs(weights).sum() * 0.5, result) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例4: test_return_l2_regularizer_weights_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_return_l2_regularizer_weights_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
          weight: 0.42
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)

    regularizer = keras_config.params()['kernel_regularizer']
    weights = np.array([1., -1, 4., 2.])
    with self.test_session() as sess:
      result = sess.run(regularizer(tf.constant(weights)))
    self.assertAllClose(np.power(weights, 2).sum() / 2.0 * 0.42, result) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例5: test_use_none_activation_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_use_none_activation_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: NONE
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    self.assertEqual(keras_config.params()['activation'], None)
    self.assertEqual(
        keras_config.params(include_activation=True)['activation'], None)
    activation_layer = keras_config.build_activation_layer()
    self.assertTrue(isinstance(activation_layer, tf.keras.layers.Lambda))
    self.assertEqual(activation_layer.function, tf.identity) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例6: test_use_relu_activation_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_use_relu_activation_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    self.assertEqual(keras_config.params()['activation'], None)
    self.assertEqual(
        keras_config.params(include_activation=True)['activation'], tf.nn.relu)
    activation_layer = keras_config.build_activation_layer()
    self.assertTrue(isinstance(activation_layer, tf.keras.layers.Lambda))
    self.assertEqual(activation_layer.function, tf.nn.relu) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例7: test_use_relu_6_activation_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_use_relu_6_activation_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU_6
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    self.assertEqual(keras_config.params()['activation'], None)
    self.assertEqual(
        keras_config.params(include_activation=True)['activation'], tf.nn.relu6)
    activation_layer = keras_config.build_activation_layer()
    self.assertTrue(isinstance(activation_layer, tf.keras.layers.Lambda))
    self.assertEqual(activation_layer.function, tf.nn.relu6) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例8: test_override_activation_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_override_activation_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU_6
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    new_params = keras_config.params(activation=tf.nn.relu)
    self.assertEqual(new_params['activation'], tf.nn.relu) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:20,代碼來源:hyperparams_builder_test.py

示例9: test_variance_in_range_with_variance_scaling_initializer_fan_in_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_variance_in_range_with_variance_scaling_initializer_fan_in_keras(
      self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_IN
          uniform: false
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    initializer = keras_config.params()['kernel_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=2. / 100.) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例10: test_variance_in_range_with_variance_scaling_initializer_fan_avg_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_variance_in_range_with_variance_scaling_initializer_fan_avg_keras(
      self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_AVG
          uniform: false
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    initializer = keras_config.params()['kernel_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=4. / (100. + 40.)) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例11: test_variance_in_range_with_variance_scaling_initializer_uniform_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_variance_in_range_with_variance_scaling_initializer_uniform_keras(
      self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_IN
          uniform: true
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    initializer = keras_config.params()['kernel_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=2. / 100.) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例12: test_variance_in_range_with_truncated_normal_initializer_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_variance_in_range_with_truncated_normal_initializer_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
          mean: 0.0
          stddev: 0.8
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    initializer = keras_config.params()['kernel_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=0.49, tol=1e-1) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:22,代碼來源:hyperparams_builder_test.py

示例13: test_variance_in_range_with_random_normal_initializer_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_variance_in_range_with_random_normal_initializer_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        random_normal_initializer {
          mean: 0.0
          stddev: 0.8
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    initializer = keras_config.params()['kernel_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=0.64, tol=1e-1) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:22,代碼來源:hyperparams_builder_test.py

示例14: test_do_not_use_batch_norm_if_default_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_do_not_use_batch_norm_if_default_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    self.assertFalse(keras_config.use_batch_norm())
    self.assertEqual(keras_config.batch_norm_params(), {})

    # The batch norm builder should build an identity Lambda layer
    identity_layer = keras_config.build_batch_norm()
    self.assertTrue(isinstance(identity_layer,
                               tf.keras.layers.Lambda)) 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Training-GUI,代碼行數:24,代碼來源:hyperparams_builder_test.py

示例15: test_use_relu_activation_keras

# 需要導入模塊: from object_detection.builders import hyperparams_builder [as 別名]
# 或者: from object_detection.builders.hyperparams_builder import KerasLayerHyperparams [as 別名]
def test_use_relu_activation_keras(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    keras_config = hyperparams_builder.KerasLayerHyperparams(
        conv_hyperparams_proto)
    self.assertEqual(keras_config.params()['activation'], tf.nn.relu) 
開發者ID:BMW-InnovationLab,項目名稱:BMW-TensorFlow-Training-GUI,代碼行數:19,代碼來源:hyperparams_builder_test.py


注:本文中的object_detection.builders.hyperparams_builder.KerasLayerHyperparams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。