欢迎访问宙启技术站
智能推送

Python中object_detection.builders.hyperparams_builder模块中build()函数的中文标题和定义

发布时间:2024-01-16 22:26:55

build()函数的中文标题为:构建超参数

build()函数的定义如下:

def build(hyperparams_config_text_proto):
    """Builds hyperparameters.

    Args:
        hyperparams_config_text_proto: Text proto hyperparameters configuration.

    Returns:
        hyperparams_proto: Message representing the Hyperparameters.

    Raises:
        ValueError: On incomplete input config.
    """

该函数用于构建超参数。

参数:

- hyperparams_config_text_proto:超参数配置的文本proto。

返回值:

- hyperparams_proto:表示超参数的消息。

异常:

- ValueError:在输入配置不完整的情况下。

使用示例:

from object_detection.protos import hyperparams_pb2
from object_detection.builders import hyperparams_builder

# 构建超参数文本proto
hyperparams_text_proto = '''
    input_shape {
      height: 300
      width: 300
    }
    num_classes: 10
    model {
      ssd {
        num_classes: 10
        feature_extractor {
          type: "ssd_mobilenet_v2"
          depth_multiplier: 1.0
        }
        loss {
          classification_loss {
            weighted_sigmoid {
              anchorwise_output: true
            }
          }
          localization_loss {
            weighted_smooth_l1 {
              anchorwise_output: true
            }
          }
          hard_example_miner {
            num_hard_examples: 3000
            iou_threshold: 0.99
          }
        }
        post_processing {
          batch_non_max_suppression {
            score_threshold: 0.3
            iou_threshold: 0.6
            max_detections_per_class: 100
            max_total_detections: 300
          }
        }
        normalize_loss_by_num_matches: true
      }
    }
    train_config {
      batch_size: 32
      optimizer {
        adadelta {
          learning_rate {
            exponential_decay_learning_rate {
              initial_learning_rate: 0.1
              decay_steps: 20000
              decay_factor: 0.96
            }
          }
        }
      }
      num_steps: 100000
    }
    eval_config {
      metrics_set: "coco_detection_metrics"
      num_examples: 8000
    }
'''

# 构建超参数
hyperparams_proto = hyperparams_builder.build(hyperparams_text_proto)

在上述示例中,我们首先导入了相应的模块。然后,我们使用超参数配置的文本proto,创建了一个示例hyperparams_text_proto。接下来,我们调用build()函数来构建超参数,将超参数配置的文本proto作为参数传递给build()函数。最后,我们获得了表示超参数的消息hyperparams_proto。