mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert D22227939: [TB] Add support for hparam domain_discrete
Test Plan: revert-hammer
Differential Revision:
D22227939 (4c25428c8c)
Original commit changeset: d2f0cd8e5632
fbshipit-source-id: c4329fcead69cb0f3d368a254d8756fb04be742d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5377827b3e
commit
502ec8f7f7
@ -1,25 +0,0 @@
|
||||
(value {
|
||||
tag: "_hparams_/experiment"
|
||||
metadata {
|
||||
plugin_data {
|
||||
plugin_name: "hparams"
|
||||
content: "\022V\"\023\n\002lr \003*\013\n\t\021\232\231\231\231\231\231\271?\"\031\n\010bool_var \003*\013\n\t\021\000\000\000\000\000\000\360?\"\026\n\nstring_var \001*\006\n\004\032\002hi*\014\n\n\022\010accuracy"
|
||||
}
|
||||
}
|
||||
}, value {
|
||||
tag: "_hparams_/session_start_info"
|
||||
metadata {
|
||||
plugin_data {
|
||||
plugin_name: "hparams"
|
||||
content: "\032<\n\017\n\002lr\022\t\021\232\231\231\231\231\231\271?\n\025\n\010bool_var\022\t\021\000\000\000\000\000\000\360?\n\022\n\nstring_var\022\004\032\002hi"
|
||||
}
|
||||
}
|
||||
}, value {
|
||||
tag: "_hparams_/session_end_info"
|
||||
metadata {
|
||||
plugin_data {
|
||||
plugin_name: "hparams"
|
||||
content: "\"\002\010\001"
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -465,12 +465,6 @@ class TestTensorBoardSummary(BaseTestCase):
|
||||
mt = {'accuracy': 0.1}
|
||||
self.assertTrue(compare_proto(summary.hparams(hp, mt), self))
|
||||
|
||||
def test_hparams_domain_discrete(self):
|
||||
hp = {"lr": 0.1, "bool_var": True, "string_var": "hi"}
|
||||
mt = {"accuracy": 0.1}
|
||||
hp_domain = {"lr": [0.1], "bool_var": [True], "string_var": ["hi"]}
|
||||
self.assertTrue(compare_proto(summary.hparams(hp, mt, hp_domain), self))
|
||||
|
||||
def test_mesh(self):
|
||||
v = np.array([[[1, 1, 1], [-1, -1, 1], [1, -1, -1], [-1, 1, -1]]], dtype=float)
|
||||
c = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255], [255, 0, 255]]], dtype=int)
|
||||
|
||||
@ -10,7 +10,6 @@ import os
|
||||
# pylint: disable=unused-import
|
||||
from six.moves import range
|
||||
|
||||
from google.protobuf import struct_pb2
|
||||
from tensorboard.compat.proto.summary_pb2 import Summary
|
||||
from tensorboard.compat.proto.summary_pb2 import HistogramProto
|
||||
from tensorboard.compat.proto.summary_pb2 import SummaryMetadata
|
||||
@ -51,7 +50,7 @@ def _draw_single_box(image, xmin, ymin, xmax, ymax, display_str, color='black',
|
||||
return image
|
||||
|
||||
|
||||
def hparams(hparam_dict=None, metric_dict=None, hparam_domain_discrete=None):
|
||||
def hparams(hparam_dict=None, metric_dict=None):
|
||||
"""Outputs three `Summary` protocol buffers needed by hparams plugin.
|
||||
`Experiment` keeps the metadata of an experiment, such as the name of the
|
||||
hyperparameters and the name of the metrics.
|
||||
@ -63,8 +62,6 @@ def hparams(hparam_dict=None, metric_dict=None, hparam_domain_discrete=None):
|
||||
and their values.
|
||||
metric_dict: A dictionary that contains names of the metrics
|
||||
and their values.
|
||||
hparam_domain_discrete: (Optional[Dict[str, List[Any]]]) A dictionary that
|
||||
contains names of the hyperparameters and all discrete values they can hold
|
||||
|
||||
Returns:
|
||||
The `Summary` protobufs for Experiment, SessionStartInfo and
|
||||
@ -102,21 +99,6 @@ def hparams(hparam_dict=None, metric_dict=None, hparam_domain_discrete=None):
|
||||
logging.warning('parameter: metric_dict should be a dictionary, nothing logged.')
|
||||
raise TypeError('parameter: metric_dict should be a dictionary, nothing logged.')
|
||||
|
||||
hparam_domain_discrete = hparam_domain_discrete or {}
|
||||
if not isinstance(hparam_domain_discrete, dict):
|
||||
raise TypeError(
|
||||
"parameter: hparam_domain_discrete should be a dictionary, nothing logged."
|
||||
)
|
||||
for k, v in hparam_domain_discrete.items():
|
||||
if (
|
||||
k not in hparam_dict
|
||||
or not isinstance(v, list)
|
||||
or not all(isinstance(d, type(hparam_dict[k])) for d in v)
|
||||
):
|
||||
raise TypeError(
|
||||
"parameter: hparam_domain_discrete[{}] should be a list of same type as "
|
||||
"hparam_dict[{}].".format(k, k)
|
||||
)
|
||||
hps = []
|
||||
|
||||
|
||||
@ -126,68 +108,17 @@ def hparams(hparam_dict=None, metric_dict=None, hparam_domain_discrete=None):
|
||||
continue
|
||||
if isinstance(v, int) or isinstance(v, float):
|
||||
ssi.hparams[k].number_value = v
|
||||
|
||||
if k in hparam_domain_discrete:
|
||||
domain_discrete = struct_pb2.ListValue(
|
||||
values=[
|
||||
struct_pb2.Value(number_value=d)
|
||||
for d in hparam_domain_discrete[k]
|
||||
]
|
||||
)
|
||||
else:
|
||||
domain_discrete = None
|
||||
|
||||
hps.append(
|
||||
HParamInfo(
|
||||
name=k,
|
||||
type=DataType.Value("DATA_TYPE_FLOAT64"),
|
||||
domain_discrete=domain_discrete,
|
||||
)
|
||||
)
|
||||
hps.append(HParamInfo(name=k, type=DataType.Value("DATA_TYPE_FLOAT64")))
|
||||
continue
|
||||
|
||||
if isinstance(v, string_types):
|
||||
ssi.hparams[k].string_value = v
|
||||
|
||||
if k in hparam_domain_discrete:
|
||||
domain_discrete = struct_pb2.ListValue(
|
||||
values=[
|
||||
struct_pb2.Value(string_value=d)
|
||||
for d in hparam_domain_discrete[k]
|
||||
]
|
||||
)
|
||||
else:
|
||||
domain_discrete = None
|
||||
|
||||
hps.append(
|
||||
HParamInfo(
|
||||
name=k,
|
||||
type=DataType.Value("DATA_TYPE_STRING"),
|
||||
domain_discrete=domain_discrete,
|
||||
)
|
||||
)
|
||||
hps.append(HParamInfo(name=k, type=DataType.Value("DATA_TYPE_STRING")))
|
||||
continue
|
||||
|
||||
if isinstance(v, bool):
|
||||
ssi.hparams[k].bool_value = v
|
||||
|
||||
if k in hparam_domain_discrete:
|
||||
domain_discrete = struct_pb2.ListValue(
|
||||
values=[
|
||||
struct_pb2.Value(bool_value=d)
|
||||
for d in hparam_domain_discrete[k]
|
||||
]
|
||||
)
|
||||
else:
|
||||
domain_discrete = None
|
||||
|
||||
hps.append(
|
||||
HParamInfo(
|
||||
name=k,
|
||||
type=DataType.Value("DATA_TYPE_BOOL"),
|
||||
domain_discrete=domain_discrete,
|
||||
)
|
||||
)
|
||||
hps.append(HParamInfo(name=k, type=DataType.Value("DATA_TYPE_BOOL")))
|
||||
continue
|
||||
|
||||
if isinstance(v, torch.Tensor):
|
||||
|
||||
@ -268,9 +268,7 @@ class SummaryWriter(object):
|
||||
"""Returns the directory where event files will be written."""
|
||||
return self.log_dir
|
||||
|
||||
def add_hparams(
|
||||
self, hparam_dict, metric_dict, hparam_domain_discrete=None, run_name=None
|
||||
):
|
||||
def add_hparams(self, hparam_dict, metric_dict, run_name=None):
|
||||
"""Add a set of hyperparameters to be compared in TensorBoard.
|
||||
|
||||
Args:
|
||||
@ -283,8 +281,6 @@ class SummaryWriter(object):
|
||||
here should be unique in the tensorboard record. Otherwise the value
|
||||
you added by ``add_scalar`` will be displayed in hparam plugin. In most
|
||||
cases, this is unwanted.
|
||||
hparam_domain_discrete: (Optional[Dict[str, List[Any]]]) A dictionary that
|
||||
contains names of the hyperparameters and all discrete values they can hold
|
||||
run_name (str): Name of the run, to be included as part of the logdir.
|
||||
If unspecified, will use current timestamp.
|
||||
|
||||
@ -305,7 +301,7 @@ class SummaryWriter(object):
|
||||
torch._C._log_api_usage_once("tensorboard.logging.add_hparams")
|
||||
if type(hparam_dict) is not dict or type(metric_dict) is not dict:
|
||||
raise TypeError('hparam_dict and metric_dict should be dictionary.')
|
||||
exp, ssi, sei = hparams(hparam_dict, metric_dict, hparam_domain_discrete)
|
||||
exp, ssi, sei = hparams(hparam_dict, metric_dict)
|
||||
|
||||
if not run_name:
|
||||
run_name = str(time.time())
|
||||
|
||||
Reference in New Issue
Block a user