예제 #1
0
def _write_hparams_config(log_dir, searchspace):
    HPARAMS = _create_hparams_config(searchspace)
    METRICS = [
        hp.Metric(
            "epoch_acc",
            group="validation",
            display_name="accuracy (val.)",
        ),
        hp.Metric(
            "epoch_loss",
            group="validation",
            display_name="loss (val.)",
        ),
        hp.Metric(
            "epoch_acc",
            group="train",
            display_name="accuracy (train)",
        ),
        hp.Metric(
            "epoch_loss",
            group="train",
            display_name="loss (train)",
        ),
    ]

    with tf.summary.create_file_writer(log_dir).as_default():
        hp.hparams_config(hparams=HPARAMS, metrics=METRICS)
예제 #2
0
def _HParamExperiment(hparams, metrics):
    from tensorboard.plugins.hparams import summary_v2 as hp

    return hp.hparams_config_pb(
        hparams=[_HParam(key, vals) for key, vals in hparams.items()],
        metrics=[hp.Metric(tag) for tag in metrics],
    )
예제 #3
0
    def setUp(self):
        self.logdir = os.path.join(self.get_temp_dir(), "logs")

        self.hparams = [
            hp.HParam("learning_rate", hp.RealInterval(1e-2, 1e-1)),
            hp.HParam("dense_layers", hp.IntInterval(2, 7)),
            hp.HParam("optimizer", hp.Discrete(["adam", "sgd"])),
            hp.HParam("who_knows_what"),
            hp.HParam(
                "magic",
                hp.Discrete([False, True]),
                display_name="~*~ Magic ~*~",
                description="descriptive",
            ),
        ]
        self.metrics = [
            hp.Metric("samples_per_second"),
            hp.Metric(group="train",
                      tag="batch_loss",
                      display_name="loss (train)"),
            hp.Metric(
                group="validation",
                tag="epoch_accuracy",
                display_name="accuracy (val.)",
                description="Accuracy on the _validation_ dataset.",
                dataset_type=hp.Metric.VALIDATION,
            ),
        ]
        self.time_created_secs = 1555624767.0

        self.expected_experiment_pb = api_pb2.Experiment()
        text_format.Merge(
            """
            time_created_secs: 1555624767.0
            hparam_infos {
              name: "learning_rate"
              type: DATA_TYPE_FLOAT64
              domain_interval {
                min_value: 0.01
                max_value: 0.1
              }
            }
            hparam_infos {
              name: "dense_layers"
              type: DATA_TYPE_FLOAT64
              domain_interval {
                min_value: 2
                max_value: 7
              }
            }
            hparam_infos {
              name: "optimizer"
              type: DATA_TYPE_STRING
              domain_discrete {
                values {
                  string_value: "adam"
                }
                values {
                  string_value: "sgd"
                }
              }
            }
            hparam_infos {
              name: "who_knows_what"
            }
            hparam_infos {
              name: "magic"
              type: DATA_TYPE_BOOL
              display_name: "~*~ Magic ~*~"
              description: "descriptive"
              domain_discrete {
                values {
                  bool_value: false
                }
                values {
                  bool_value: true
                }
              }
            }
            metric_infos {
              name {
                tag: "samples_per_second"
              }
            }
            metric_infos {
              name {
                group: "train"
                tag: "batch_loss"
              }
              display_name: "loss (train)"
            }
            metric_infos {
              name {
                group: "validation"
                tag: "epoch_accuracy"
              }
              display_name: "accuracy (val.)"
              description: "Accuracy on the _validation_ dataset."
              dataset_type: DATASET_VALIDATION
            }
            """,
            self.expected_experiment_pb,
        )
예제 #4
0
def Metric(tag):
    return hp.Metric(tag)