tensorbored 2.21.0rc1769983804__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tensorbored/__init__.py +112 -0
- tensorbored/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/__init__.py +125 -0
- tensorbored/_vendor/bleach/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/__init__.py +35 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_ihatexml.py +289 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_inputstream.py +918 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_tokenizer.py +1735 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/__init__.py +5 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/_base.py +40 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/py.py +67 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_utils.py +159 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/constants.py +2946 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/base.py +12 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/lint.py +93 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/optionaltags.py +207 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/sanitizer.py +916 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/whitespace.py +38 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/html5parser.py +2795 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/serializer.py +409 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/__init__.py +30 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/genshi.py +54 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/sax.py +50 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/__init__.py +88 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/base.py +417 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/dom.py +239 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree.py +343 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/__init__.py +154 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/base.py +252 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/dom.py +43 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree.py +131 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/genshi.py +69 -0
- tensorbored/_vendor/bleach/_vendor/parse.py +1078 -0
- tensorbored/_vendor/bleach/callbacks.py +32 -0
- tensorbored/_vendor/bleach/html5lib_shim.py +757 -0
- tensorbored/_vendor/bleach/linkifier.py +633 -0
- tensorbored/_vendor/bleach/parse_shim.py +1 -0
- tensorbored/_vendor/bleach/sanitizer.py +638 -0
- tensorbored/_vendor/bleach/six_shim.py +19 -0
- tensorbored/_vendor/webencodings/__init__.py +342 -0
- tensorbored/_vendor/webencodings/labels.py +231 -0
- tensorbored/_vendor/webencodings/mklabels.py +59 -0
- tensorbored/_vendor/webencodings/x_user_defined.py +325 -0
- tensorbored/assets.py +36 -0
- tensorbored/auth.py +102 -0
- tensorbored/backend/__init__.py +0 -0
- tensorbored/backend/application.py +604 -0
- tensorbored/backend/auth_context_middleware.py +38 -0
- tensorbored/backend/client_feature_flags.py +113 -0
- tensorbored/backend/empty_path_redirect.py +46 -0
- tensorbored/backend/event_processing/__init__.py +0 -0
- tensorbored/backend/event_processing/data_ingester.py +276 -0
- tensorbored/backend/event_processing/data_provider.py +535 -0
- tensorbored/backend/event_processing/directory_loader.py +142 -0
- tensorbored/backend/event_processing/directory_watcher.py +272 -0
- tensorbored/backend/event_processing/event_accumulator.py +950 -0
- tensorbored/backend/event_processing/event_file_inspector.py +463 -0
- tensorbored/backend/event_processing/event_file_loader.py +292 -0
- tensorbored/backend/event_processing/event_multiplexer.py +521 -0
- tensorbored/backend/event_processing/event_util.py +68 -0
- tensorbored/backend/event_processing/io_wrapper.py +223 -0
- tensorbored/backend/event_processing/plugin_asset_util.py +104 -0
- tensorbored/backend/event_processing/plugin_event_accumulator.py +721 -0
- tensorbored/backend/event_processing/plugin_event_multiplexer.py +522 -0
- tensorbored/backend/event_processing/reservoir.py +266 -0
- tensorbored/backend/event_processing/tag_types.py +29 -0
- tensorbored/backend/experiment_id.py +71 -0
- tensorbored/backend/experimental_plugin.py +51 -0
- tensorbored/backend/http_util.py +263 -0
- tensorbored/backend/json_util.py +70 -0
- tensorbored/backend/path_prefix.py +67 -0
- tensorbored/backend/process_graph.py +74 -0
- tensorbored/backend/security_validator.py +202 -0
- tensorbored/compat/__init__.py +69 -0
- tensorbored/compat/proto/__init__.py +0 -0
- tensorbored/compat/proto/allocation_description_pb2.py +35 -0
- tensorbored/compat/proto/api_def_pb2.py +82 -0
- tensorbored/compat/proto/attr_value_pb2.py +80 -0
- tensorbored/compat/proto/cluster_pb2.py +58 -0
- tensorbored/compat/proto/config_pb2.py +271 -0
- tensorbored/compat/proto/coordination_config_pb2.py +45 -0
- tensorbored/compat/proto/cost_graph_pb2.py +87 -0
- tensorbored/compat/proto/cpp_shape_inference_pb2.py +70 -0
- tensorbored/compat/proto/debug_pb2.py +65 -0
- tensorbored/compat/proto/event_pb2.py +149 -0
- tensorbored/compat/proto/full_type_pb2.py +74 -0
- tensorbored/compat/proto/function_pb2.py +157 -0
- tensorbored/compat/proto/graph_debug_info_pb2.py +111 -0
- tensorbored/compat/proto/graph_pb2.py +41 -0
- tensorbored/compat/proto/histogram_pb2.py +39 -0
- tensorbored/compat/proto/meta_graph_pb2.py +254 -0
- tensorbored/compat/proto/node_def_pb2.py +61 -0
- tensorbored/compat/proto/op_def_pb2.py +81 -0
- tensorbored/compat/proto/resource_handle_pb2.py +48 -0
- tensorbored/compat/proto/rewriter_config_pb2.py +93 -0
- tensorbored/compat/proto/rpc_options_pb2.py +35 -0
- tensorbored/compat/proto/saved_object_graph_pb2.py +193 -0
- tensorbored/compat/proto/saver_pb2.py +38 -0
- tensorbored/compat/proto/step_stats_pb2.py +116 -0
- tensorbored/compat/proto/struct_pb2.py +144 -0
- tensorbored/compat/proto/summary_pb2.py +111 -0
- tensorbored/compat/proto/tensor_description_pb2.py +38 -0
- tensorbored/compat/proto/tensor_pb2.py +68 -0
- tensorbored/compat/proto/tensor_shape_pb2.py +46 -0
- tensorbored/compat/proto/tfprof_log_pb2.py +307 -0
- tensorbored/compat/proto/trackable_object_graph_pb2.py +90 -0
- tensorbored/compat/proto/types_pb2.py +105 -0
- tensorbored/compat/proto/variable_pb2.py +62 -0
- tensorbored/compat/proto/verifier_config_pb2.py +38 -0
- tensorbored/compat/proto/versions_pb2.py +35 -0
- tensorbored/compat/tensorflow_stub/__init__.py +38 -0
- tensorbored/compat/tensorflow_stub/app.py +124 -0
- tensorbored/compat/tensorflow_stub/compat/__init__.py +131 -0
- tensorbored/compat/tensorflow_stub/compat/v1/__init__.py +20 -0
- tensorbored/compat/tensorflow_stub/dtypes.py +692 -0
- tensorbored/compat/tensorflow_stub/error_codes.py +169 -0
- tensorbored/compat/tensorflow_stub/errors.py +507 -0
- tensorbored/compat/tensorflow_stub/flags.py +124 -0
- tensorbored/compat/tensorflow_stub/io/__init__.py +17 -0
- tensorbored/compat/tensorflow_stub/io/gfile.py +1011 -0
- tensorbored/compat/tensorflow_stub/pywrap_tensorflow.py +285 -0
- tensorbored/compat/tensorflow_stub/tensor_shape.py +1035 -0
- tensorbored/context.py +129 -0
- tensorbored/data/__init__.py +0 -0
- tensorbored/data/grpc_provider.py +365 -0
- tensorbored/data/ingester.py +46 -0
- tensorbored/data/proto/__init__.py +0 -0
- tensorbored/data/proto/data_provider_pb2.py +517 -0
- tensorbored/data/proto/data_provider_pb2_grpc.py +374 -0
- tensorbored/data/provider.py +1365 -0
- tensorbored/data/server_ingester.py +301 -0
- tensorbored/data_compat.py +159 -0
- tensorbored/dataclass_compat.py +224 -0
- tensorbored/default.py +124 -0
- tensorbored/errors.py +130 -0
- tensorbored/lazy.py +99 -0
- tensorbored/main.py +48 -0
- tensorbored/main_lib.py +62 -0
- tensorbored/manager.py +487 -0
- tensorbored/notebook.py +441 -0
- tensorbored/plugin_util.py +266 -0
- tensorbored/plugins/__init__.py +0 -0
- tensorbored/plugins/audio/__init__.py +0 -0
- tensorbored/plugins/audio/audio_plugin.py +229 -0
- tensorbored/plugins/audio/metadata.py +69 -0
- tensorbored/plugins/audio/plugin_data_pb2.py +37 -0
- tensorbored/plugins/audio/summary.py +230 -0
- tensorbored/plugins/audio/summary_v2.py +124 -0
- tensorbored/plugins/base_plugin.py +367 -0
- tensorbored/plugins/core/__init__.py +0 -0
- tensorbored/plugins/core/core_plugin.py +981 -0
- tensorbored/plugins/custom_scalar/__init__.py +0 -0
- tensorbored/plugins/custom_scalar/custom_scalars_plugin.py +320 -0
- tensorbored/plugins/custom_scalar/layout_pb2.py +85 -0
- tensorbored/plugins/custom_scalar/metadata.py +35 -0
- tensorbored/plugins/custom_scalar/summary.py +79 -0
- tensorbored/plugins/debugger_v2/__init__.py +0 -0
- tensorbored/plugins/debugger_v2/debug_data_multiplexer.py +631 -0
- tensorbored/plugins/debugger_v2/debug_data_provider.py +634 -0
- tensorbored/plugins/debugger_v2/debugger_v2_plugin.py +504 -0
- tensorbored/plugins/distribution/__init__.py +0 -0
- tensorbored/plugins/distribution/compressor.py +158 -0
- tensorbored/plugins/distribution/distributions_plugin.py +116 -0
- tensorbored/plugins/distribution/metadata.py +19 -0
- tensorbored/plugins/graph/__init__.py +0 -0
- tensorbored/plugins/graph/graph_util.py +129 -0
- tensorbored/plugins/graph/graphs_plugin.py +336 -0
- tensorbored/plugins/graph/keras_util.py +328 -0
- tensorbored/plugins/graph/metadata.py +42 -0
- tensorbored/plugins/histogram/__init__.py +0 -0
- tensorbored/plugins/histogram/histograms_plugin.py +144 -0
- tensorbored/plugins/histogram/metadata.py +63 -0
- tensorbored/plugins/histogram/plugin_data_pb2.py +34 -0
- tensorbored/plugins/histogram/summary.py +234 -0
- tensorbored/plugins/histogram/summary_v2.py +292 -0
- tensorbored/plugins/hparams/__init__.py +14 -0
- tensorbored/plugins/hparams/_keras.py +93 -0
- tensorbored/plugins/hparams/api.py +130 -0
- tensorbored/plugins/hparams/api_pb2.py +208 -0
- tensorbored/plugins/hparams/backend_context.py +606 -0
- tensorbored/plugins/hparams/download_data.py +158 -0
- tensorbored/plugins/hparams/error.py +26 -0
- tensorbored/plugins/hparams/get_experiment.py +71 -0
- tensorbored/plugins/hparams/hparams_plugin.py +206 -0
- tensorbored/plugins/hparams/hparams_util_pb2.py +69 -0
- tensorbored/plugins/hparams/json_format_compat.py +38 -0
- tensorbored/plugins/hparams/list_metric_evals.py +57 -0
- tensorbored/plugins/hparams/list_session_groups.py +1040 -0
- tensorbored/plugins/hparams/metadata.py +125 -0
- tensorbored/plugins/hparams/metrics.py +41 -0
- tensorbored/plugins/hparams/plugin_data_pb2.py +69 -0
- tensorbored/plugins/hparams/summary.py +205 -0
- tensorbored/plugins/hparams/summary_v2.py +597 -0
- tensorbored/plugins/image/__init__.py +0 -0
- tensorbored/plugins/image/images_plugin.py +232 -0
- tensorbored/plugins/image/metadata.py +65 -0
- tensorbored/plugins/image/plugin_data_pb2.py +34 -0
- tensorbored/plugins/image/summary.py +159 -0
- tensorbored/plugins/image/summary_v2.py +130 -0
- tensorbored/plugins/mesh/__init__.py +14 -0
- tensorbored/plugins/mesh/mesh_plugin.py +292 -0
- tensorbored/plugins/mesh/metadata.py +152 -0
- tensorbored/plugins/mesh/plugin_data_pb2.py +37 -0
- tensorbored/plugins/mesh/summary.py +251 -0
- tensorbored/plugins/mesh/summary_v2.py +214 -0
- tensorbored/plugins/metrics/__init__.py +0 -0
- tensorbored/plugins/metrics/metadata.py +17 -0
- tensorbored/plugins/metrics/metrics_plugin.py +623 -0
- tensorbored/plugins/pr_curve/__init__.py +0 -0
- tensorbored/plugins/pr_curve/metadata.py +75 -0
- tensorbored/plugins/pr_curve/plugin_data_pb2.py +34 -0
- tensorbored/plugins/pr_curve/pr_curves_plugin.py +241 -0
- tensorbored/plugins/pr_curve/summary.py +574 -0
- tensorbored/plugins/profile_redirect/__init__.py +0 -0
- tensorbored/plugins/profile_redirect/profile_redirect_plugin.py +49 -0
- tensorbored/plugins/projector/__init__.py +67 -0
- tensorbored/plugins/projector/metadata.py +26 -0
- tensorbored/plugins/projector/projector_config_pb2.py +54 -0
- tensorbored/plugins/projector/projector_plugin.py +795 -0
- tensorbored/plugins/projector/tf_projector_plugin/index.js +32 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.html +524 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.js +15536 -0
- tensorbored/plugins/scalar/__init__.py +0 -0
- tensorbored/plugins/scalar/metadata.py +60 -0
- tensorbored/plugins/scalar/plugin_data_pb2.py +34 -0
- tensorbored/plugins/scalar/scalars_plugin.py +181 -0
- tensorbored/plugins/scalar/summary.py +109 -0
- tensorbored/plugins/scalar/summary_v2.py +124 -0
- tensorbored/plugins/text/__init__.py +0 -0
- tensorbored/plugins/text/metadata.py +62 -0
- tensorbored/plugins/text/plugin_data_pb2.py +34 -0
- tensorbored/plugins/text/summary.py +114 -0
- tensorbored/plugins/text/summary_v2.py +124 -0
- tensorbored/plugins/text/text_plugin.py +288 -0
- tensorbored/plugins/wit_redirect/__init__.py +0 -0
- tensorbored/plugins/wit_redirect/wit_redirect_plugin.py +49 -0
- tensorbored/program.py +910 -0
- tensorbored/summary/__init__.py +35 -0
- tensorbored/summary/_output.py +124 -0
- tensorbored/summary/_tf/__init__.py +14 -0
- tensorbored/summary/_tf/summary/__init__.py +178 -0
- tensorbored/summary/_writer.py +105 -0
- tensorbored/summary/v1.py +51 -0
- tensorbored/summary/v2.py +25 -0
- tensorbored/summary/writer/__init__.py +13 -0
- tensorbored/summary/writer/event_file_writer.py +291 -0
- tensorbored/summary/writer/record_writer.py +50 -0
- tensorbored/util/__init__.py +0 -0
- tensorbored/util/encoder.py +116 -0
- tensorbored/util/grpc_util.py +311 -0
- tensorbored/util/img_mime_type_detector.py +40 -0
- tensorbored/util/io_util.py +20 -0
- tensorbored/util/lazy_tensor_creator.py +110 -0
- tensorbored/util/op_evaluator.py +104 -0
- tensorbored/util/platform_util.py +20 -0
- tensorbored/util/tb_logging.py +24 -0
- tensorbored/util/tensor_util.py +617 -0
- tensorbored/util/timing.py +122 -0
- tensorbored/version.py +21 -0
- tensorbored/webfiles.zip +0 -0
- tensorbored-2.21.0rc1769983804.dist-info/METADATA +49 -0
- tensorbored-2.21.0rc1769983804.dist-info/RECORD +271 -0
- tensorbored-2.21.0rc1769983804.dist-info/WHEEL +5 -0
- tensorbored-2.21.0rc1769983804.dist-info/entry_points.txt +6 -0
- tensorbored-2.21.0rc1769983804.dist-info/licenses/LICENSE +739 -0
- tensorbored-2.21.0rc1769983804.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Constants used in the HParams plugin."""
|
|
16
|
+
|
|
17
|
+
from tensorbored.compat.proto import summary_pb2
|
|
18
|
+
from tensorbored.compat.proto import types_pb2
|
|
19
|
+
from tensorbored.plugins.hparams import error
|
|
20
|
+
from tensorbored.plugins.hparams import plugin_data_pb2
|
|
21
|
+
from tensorbored.util import tensor_util
|
|
22
|
+
|
|
23
|
+
PLUGIN_NAME = "hparams"
|
|
24
|
+
PLUGIN_DATA_VERSION = 0
|
|
25
|
+
|
|
26
|
+
# Tensor value for use in summaries that really only need to store
|
|
27
|
+
# metadata. A length-0 float vector is of minimal serialized length
|
|
28
|
+
# (6 bytes) among valid tensors. Cache this: computing it takes on the
|
|
29
|
+
# order of tens of microseconds.
|
|
30
|
+
NULL_TENSOR = tensor_util.make_tensor_proto(
|
|
31
|
+
[], dtype=types_pb2.DT_FLOAT, shape=(0,)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
EXPERIMENT_TAG = "_hparams_/experiment"
|
|
35
|
+
SESSION_START_INFO_TAG = "_hparams_/session_start_info"
|
|
36
|
+
SESSION_END_INFO_TAG = "_hparams_/session_end_info"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def create_summary_metadata(hparams_plugin_data_pb):
|
|
40
|
+
"""Returns a summary metadata for the HParams plugin.
|
|
41
|
+
|
|
42
|
+
Returns a summary_pb2.SummaryMetadata holding a copy of the given
|
|
43
|
+
HParamsPluginData message in its plugin_data.content field.
|
|
44
|
+
Sets the version field of the hparams_plugin_data_pb copy to
|
|
45
|
+
PLUGIN_DATA_VERSION.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
hparams_plugin_data_pb: the HParamsPluginData protobuffer to use.
|
|
49
|
+
"""
|
|
50
|
+
if not isinstance(
|
|
51
|
+
hparams_plugin_data_pb, plugin_data_pb2.HParamsPluginData
|
|
52
|
+
):
|
|
53
|
+
raise TypeError(
|
|
54
|
+
"Needed an instance of plugin_data_pb2.HParamsPluginData."
|
|
55
|
+
" Got: %s" % type(hparams_plugin_data_pb)
|
|
56
|
+
)
|
|
57
|
+
content = plugin_data_pb2.HParamsPluginData()
|
|
58
|
+
content.CopyFrom(hparams_plugin_data_pb)
|
|
59
|
+
content.version = PLUGIN_DATA_VERSION
|
|
60
|
+
return summary_pb2.SummaryMetadata(
|
|
61
|
+
plugin_data=summary_pb2.SummaryMetadata.PluginData(
|
|
62
|
+
plugin_name=PLUGIN_NAME, content=content.SerializeToString()
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def parse_experiment_plugin_data(content):
|
|
68
|
+
"""Returns the experiment from HParam's
|
|
69
|
+
SummaryMetadata.plugin_data.content.
|
|
70
|
+
|
|
71
|
+
Raises HParamsError if the content doesn't have 'experiment' set or
|
|
72
|
+
this file is incompatible with the version of the metadata stored.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
content: The SummaryMetadata.plugin_data.content to use.
|
|
76
|
+
"""
|
|
77
|
+
return _parse_plugin_data_as(content, "experiment")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def parse_session_start_info_plugin_data(content):
|
|
81
|
+
"""Returns session_start_info from the plugin_data.content.
|
|
82
|
+
|
|
83
|
+
Raises HParamsError if the content doesn't have 'session_start_info' set or
|
|
84
|
+
this file is incompatible with the version of the metadata stored.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
content: The SummaryMetadata.plugin_data.content to use.
|
|
88
|
+
"""
|
|
89
|
+
return _parse_plugin_data_as(content, "session_start_info")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def parse_session_end_info_plugin_data(content):
|
|
93
|
+
"""Returns session_end_info from the plugin_data.content.
|
|
94
|
+
|
|
95
|
+
Raises HParamsError if the content doesn't have 'session_end_info' set or
|
|
96
|
+
this file is incompatible with the version of the metadata stored.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
content: The SummaryMetadata.plugin_data.content to use.
|
|
100
|
+
"""
|
|
101
|
+
return _parse_plugin_data_as(content, "session_end_info")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _parse_plugin_data_as(content, data_oneof_field):
|
|
105
|
+
"""Returns a data oneof's field from plugin_data.content.
|
|
106
|
+
|
|
107
|
+
Raises HParamsError if the content doesn't have 'data_oneof_field' set or
|
|
108
|
+
this file is incompatible with the version of the metadata stored.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
content: The SummaryMetadata.plugin_data.content to use.
|
|
112
|
+
data_oneof_field: string. The name of the data oneof field to return.
|
|
113
|
+
"""
|
|
114
|
+
plugin_data = plugin_data_pb2.HParamsPluginData.FromString(content)
|
|
115
|
+
if plugin_data.version != PLUGIN_DATA_VERSION:
|
|
116
|
+
raise error.HParamsError(
|
|
117
|
+
"Only supports plugin_data version: %s; found: %s in: %s"
|
|
118
|
+
% (PLUGIN_DATA_VERSION, plugin_data.version, plugin_data)
|
|
119
|
+
)
|
|
120
|
+
if not plugin_data.HasField(data_oneof_field):
|
|
121
|
+
raise error.HParamsError(
|
|
122
|
+
"Expected plugin_data.%s to be set. Got: %s"
|
|
123
|
+
% (data_oneof_field, plugin_data)
|
|
124
|
+
)
|
|
125
|
+
return getattr(plugin_data, data_oneof_field)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Functions for dealing with metrics."""
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
from tensorbored.plugins.hparams import api_pb2
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def run_tag_from_session_and_metric(session_name, metric_name):
|
|
24
|
+
"""Returns a (run,tag) tuple storing the evaluations of the specified
|
|
25
|
+
metric.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
session_name: str.
|
|
29
|
+
metric_name: MetricName protobuffer.
|
|
30
|
+
Returns: (run, tag) tuple.
|
|
31
|
+
"""
|
|
32
|
+
assert isinstance(session_name, str)
|
|
33
|
+
assert isinstance(metric_name, api_pb2.MetricName)
|
|
34
|
+
# os.path.join() will append a final slash if the group is empty; it seems
|
|
35
|
+
# like multiplexer.Tensors won't recognize paths that end with a '/' so
|
|
36
|
+
# we remove the final '/' in that case.
|
|
37
|
+
run = os.path.join(session_name, metric_name.group)
|
|
38
|
+
if run.endswith("/"):
|
|
39
|
+
run = run[:-1]
|
|
40
|
+
tag = metric_name.tag
|
|
41
|
+
return run, tag
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: tensorbored/plugins/hparams/plugin_data.proto
|
|
4
|
+
"""Generated protocol buffer code."""
|
|
5
|
+
from google.protobuf import descriptor as _descriptor
|
|
6
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
7
|
+
from google.protobuf import message as _message
|
|
8
|
+
from google.protobuf import reflection as _reflection
|
|
9
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
10
|
+
# @@protoc_insertion_point(imports)
|
|
11
|
+
|
|
12
|
+
_sym_db = _symbol_database.Default()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from tensorbored.plugins.hparams import api_pb2 as tensorbored_dot_plugins_dot_hparams_dot_api__pb2
|
|
16
|
+
from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n-tensorbored/plugins/hparams/plugin_data.proto\x12\x13tensorbored.hparams\x1a%tensorbored/plugins/hparams/api.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xe9\x01\n\x11HParamsPluginData\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12\x35\n\nexperiment\x18\x02 \x01(\x0b\x32\x1f.tensorbored.hparams.ExperimentH\x00\x12\x43\n\x12session_start_info\x18\x03 \x01(\x0b\x32%.tensorbored.hparams.SessionStartInfoH\x00\x12?\n\x10session_end_info\x18\x04 \x01(\x0b\x32#.tensorbored.hparams.SessionEndInfoH\x00\x42\x06\n\x04\x64\x61ta\"\xf4\x01\n\x10SessionStartInfo\x12\x43\n\x07hparams\x18\x01 \x03(\x0b\x32\x32.tensorbored.hparams.SessionStartInfo.HparamsEntry\x12\x11\n\tmodel_uri\x18\x02 \x01(\t\x12\x13\n\x0bmonitor_url\x18\x03 \x01(\t\x12\x12\n\ngroup_name\x18\x04 \x01(\t\x12\x17\n\x0fstart_time_secs\x18\x05 \x01(\x01\x1a\x46\n\x0cHparamsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.google.protobuf.Value:\x02\x38\x01\"T\n\x0eSessionEndInfo\x12+\n\x06status\x18\x01 \x01(\x0e\x32\x1b.tensorbored.hparams.Status\x12\x15\n\rend_time_secs\x18\x02 \x01(\x01\x62\x06proto3')
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_HPARAMSPLUGINDATA = DESCRIPTOR.message_types_by_name['HParamsPluginData']
|
|
24
|
+
_SESSIONSTARTINFO = DESCRIPTOR.message_types_by_name['SessionStartInfo']
|
|
25
|
+
_SESSIONSTARTINFO_HPARAMSENTRY = _SESSIONSTARTINFO.nested_types_by_name['HparamsEntry']
|
|
26
|
+
_SESSIONENDINFO = DESCRIPTOR.message_types_by_name['SessionEndInfo']
|
|
27
|
+
HParamsPluginData = _reflection.GeneratedProtocolMessageType('HParamsPluginData', (_message.Message,), {
|
|
28
|
+
'DESCRIPTOR' : _HPARAMSPLUGINDATA,
|
|
29
|
+
'__module__' : 'tensorbored.plugins.hparams.plugin_data_pb2'
|
|
30
|
+
# @@protoc_insertion_point(class_scope:tensorbored.hparams.HParamsPluginData)
|
|
31
|
+
})
|
|
32
|
+
_sym_db.RegisterMessage(HParamsPluginData)
|
|
33
|
+
|
|
34
|
+
SessionStartInfo = _reflection.GeneratedProtocolMessageType('SessionStartInfo', (_message.Message,), {
|
|
35
|
+
|
|
36
|
+
'HparamsEntry' : _reflection.GeneratedProtocolMessageType('HparamsEntry', (_message.Message,), {
|
|
37
|
+
'DESCRIPTOR' : _SESSIONSTARTINFO_HPARAMSENTRY,
|
|
38
|
+
'__module__' : 'tensorbored.plugins.hparams.plugin_data_pb2'
|
|
39
|
+
# @@protoc_insertion_point(class_scope:tensorbored.hparams.SessionStartInfo.HparamsEntry)
|
|
40
|
+
})
|
|
41
|
+
,
|
|
42
|
+
'DESCRIPTOR' : _SESSIONSTARTINFO,
|
|
43
|
+
'__module__' : 'tensorbored.plugins.hparams.plugin_data_pb2'
|
|
44
|
+
# @@protoc_insertion_point(class_scope:tensorbored.hparams.SessionStartInfo)
|
|
45
|
+
})
|
|
46
|
+
_sym_db.RegisterMessage(SessionStartInfo)
|
|
47
|
+
_sym_db.RegisterMessage(SessionStartInfo.HparamsEntry)
|
|
48
|
+
|
|
49
|
+
SessionEndInfo = _reflection.GeneratedProtocolMessageType('SessionEndInfo', (_message.Message,), {
|
|
50
|
+
'DESCRIPTOR' : _SESSIONENDINFO,
|
|
51
|
+
'__module__' : 'tensorbored.plugins.hparams.plugin_data_pb2'
|
|
52
|
+
# @@protoc_insertion_point(class_scope:tensorbored.hparams.SessionEndInfo)
|
|
53
|
+
})
|
|
54
|
+
_sym_db.RegisterMessage(SessionEndInfo)
|
|
55
|
+
|
|
56
|
+
if _descriptor._USE_C_DESCRIPTORS == False:
|
|
57
|
+
|
|
58
|
+
DESCRIPTOR._options = None
|
|
59
|
+
_SESSIONSTARTINFO_HPARAMSENTRY._options = None
|
|
60
|
+
_SESSIONSTARTINFO_HPARAMSENTRY._serialized_options = b'8\001'
|
|
61
|
+
_HPARAMSPLUGINDATA._serialized_start=140
|
|
62
|
+
_HPARAMSPLUGINDATA._serialized_end=373
|
|
63
|
+
_SESSIONSTARTINFO._serialized_start=376
|
|
64
|
+
_SESSIONSTARTINFO._serialized_end=620
|
|
65
|
+
_SESSIONSTARTINFO_HPARAMSENTRY._serialized_start=550
|
|
66
|
+
_SESSIONSTARTINFO_HPARAMSENTRY._serialized_end=620
|
|
67
|
+
_SESSIONENDINFO._serialized_start=622
|
|
68
|
+
_SESSIONENDINFO._serialized_end=706
|
|
69
|
+
# @@protoc_insertion_point(module_scope)
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Summary creation methods for the HParams plugin.
|
|
16
|
+
|
|
17
|
+
Typical usage for exporting summaries in a hyperparameters-tuning experiment:
|
|
18
|
+
1. Create the experiment (once) by calling experiment_pb() and exporting
|
|
19
|
+
the resulting summary into a top-level (empty) run.
|
|
20
|
+
2. In each training session in the experiment, call session_start_pb() before
|
|
21
|
+
the session starts, exporting the resulting summary into a uniquely named
|
|
22
|
+
run for the session, say <session_name>.
|
|
23
|
+
3. Train the model in the session, exporting each metric as a scalar summary
|
|
24
|
+
in runs of the form <session_name>/<sub_dir>, where <sub_dir> can be empty a
|
|
25
|
+
(in which case the run is just the <session_name>) and depends on the
|
|
26
|
+
metric. The name of such a metric is a (group, tag) pair given by
|
|
27
|
+
(<sub_dir>, tag) where tag is the tag of the scalar summary.
|
|
28
|
+
When calling experiment_pb in step 1, you'll need to pass all the metric
|
|
29
|
+
names used in the experiemnt.
|
|
30
|
+
4. When the session completes, call session_end_pb() and export the resulting
|
|
31
|
+
summary into the same session run <session_name>.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
import time
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
import tensorflow as tf
|
|
38
|
+
|
|
39
|
+
from tensorbored.plugins.hparams import api_pb2
|
|
40
|
+
from tensorbored.plugins.hparams import metadata
|
|
41
|
+
from tensorbored.plugins.hparams import plugin_data_pb2
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def experiment_pb(
|
|
45
|
+
hparam_infos, metric_infos, user="", description="", time_created_secs=None
|
|
46
|
+
):
|
|
47
|
+
"""Creates a summary that defines a hyperparameter-tuning experiment.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
hparam_infos: Array of api_pb2.HParamInfo messages. Describes the
|
|
51
|
+
hyperparameters used in the experiment.
|
|
52
|
+
metric_infos: Array of api_pb2.MetricInfo messages. Describes the metrics
|
|
53
|
+
used in the experiment. See the documentation at the top of this file
|
|
54
|
+
for how to populate this.
|
|
55
|
+
user: String. An id for the user running the experiment
|
|
56
|
+
description: String. A description for the experiment. May contain markdown.
|
|
57
|
+
time_created_secs: float. The time the experiment is created in seconds
|
|
58
|
+
since the UNIX epoch. If None uses the current time.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
A summary protobuffer containing the experiment definition.
|
|
62
|
+
"""
|
|
63
|
+
if time_created_secs is None:
|
|
64
|
+
time_created_secs = time.time()
|
|
65
|
+
experiment = api_pb2.Experiment(
|
|
66
|
+
description=description,
|
|
67
|
+
user=user,
|
|
68
|
+
time_created_secs=time_created_secs,
|
|
69
|
+
hparam_infos=hparam_infos,
|
|
70
|
+
metric_infos=metric_infos,
|
|
71
|
+
)
|
|
72
|
+
return _summary(
|
|
73
|
+
metadata.EXPERIMENT_TAG,
|
|
74
|
+
plugin_data_pb2.HParamsPluginData(experiment=experiment),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def session_start_pb(
|
|
79
|
+
hparams, model_uri="", monitor_url="", group_name="", start_time_secs=None
|
|
80
|
+
):
|
|
81
|
+
"""Constructs a SessionStartInfo protobuffer.
|
|
82
|
+
|
|
83
|
+
Creates a summary that contains a training session metadata information.
|
|
84
|
+
One such summary per training session should be created. Each should have
|
|
85
|
+
a different run.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
hparams: A dictionary with string keys. Describes the hyperparameter values
|
|
89
|
+
used in the session, mapping each hyperparameter name to its value.
|
|
90
|
+
Supported value types are `bool`, `int`, `float`, `str`, `list`,
|
|
91
|
+
`tuple`.
|
|
92
|
+
The type of value must correspond to the type of hyperparameter
|
|
93
|
+
(defined in the corresponding api_pb2.HParamInfo member of the
|
|
94
|
+
Experiment protobuf) as follows:
|
|
95
|
+
|
|
96
|
+
+-----------------+---------------------------------+
|
|
97
|
+
|Hyperparameter | Allowed (Python) value types |
|
|
98
|
+
|type | |
|
|
99
|
+
+-----------------+---------------------------------+
|
|
100
|
+
|DATA_TYPE_BOOL | bool |
|
|
101
|
+
|DATA_TYPE_FLOAT64| int, float |
|
|
102
|
+
|DATA_TYPE_STRING | str, tuple, list |
|
|
103
|
+
+-----------------+---------------------------------+
|
|
104
|
+
|
|
105
|
+
Tuple and list instances will be converted to their string
|
|
106
|
+
representation.
|
|
107
|
+
model_uri: See the comment for the field with the same name of
|
|
108
|
+
plugin_data_pb2.SessionStartInfo.
|
|
109
|
+
monitor_url: See the comment for the field with the same name of
|
|
110
|
+
plugin_data_pb2.SessionStartInfo.
|
|
111
|
+
group_name: See the comment for the field with the same name of
|
|
112
|
+
plugin_data_pb2.SessionStartInfo.
|
|
113
|
+
start_time_secs: float. The time to use as the session start time.
|
|
114
|
+
Represented as seconds since the UNIX epoch. If None uses
|
|
115
|
+
the current time.
|
|
116
|
+
Returns:
|
|
117
|
+
The summary protobuffer mentioned above.
|
|
118
|
+
"""
|
|
119
|
+
if start_time_secs is None:
|
|
120
|
+
start_time_secs = time.time()
|
|
121
|
+
session_start_info = plugin_data_pb2.SessionStartInfo(
|
|
122
|
+
model_uri=model_uri,
|
|
123
|
+
monitor_url=monitor_url,
|
|
124
|
+
group_name=group_name,
|
|
125
|
+
start_time_secs=start_time_secs,
|
|
126
|
+
)
|
|
127
|
+
for hp_name, hp_val in hparams.items():
|
|
128
|
+
# Boolean typed values need to be checked before integers since in Python
|
|
129
|
+
# isinstance(True/False, int) returns True.
|
|
130
|
+
if isinstance(hp_val, bool):
|
|
131
|
+
session_start_info.hparams[hp_name].bool_value = hp_val
|
|
132
|
+
elif isinstance(hp_val, (float, int)):
|
|
133
|
+
session_start_info.hparams[hp_name].number_value = hp_val
|
|
134
|
+
elif isinstance(hp_val, str):
|
|
135
|
+
session_start_info.hparams[hp_name].string_value = hp_val
|
|
136
|
+
elif isinstance(hp_val, (list, tuple)):
|
|
137
|
+
session_start_info.hparams[hp_name].string_value = str(hp_val)
|
|
138
|
+
else:
|
|
139
|
+
raise TypeError(
|
|
140
|
+
"hparams[%s]=%s has type: %s which is not supported"
|
|
141
|
+
% (hp_name, hp_val, type(hp_val))
|
|
142
|
+
)
|
|
143
|
+
return _summary(
|
|
144
|
+
metadata.SESSION_START_INFO_TAG,
|
|
145
|
+
plugin_data_pb2.HParamsPluginData(
|
|
146
|
+
session_start_info=session_start_info
|
|
147
|
+
),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def session_end_pb(status, end_time_secs=None):
|
|
152
|
+
"""Constructs a SessionEndInfo protobuffer.
|
|
153
|
+
|
|
154
|
+
Creates a summary that contains status information for a completed
|
|
155
|
+
training session. Should be exported after the training session is completed.
|
|
156
|
+
One such summary per training session should be created. Each should have
|
|
157
|
+
a different run.
|
|
158
|
+
|
|
159
|
+
Args:
|
|
160
|
+
status: A tensorboard.hparams.Status enumeration value denoting the
|
|
161
|
+
status of the session.
|
|
162
|
+
end_time_secs: float. The time to use as the session end time. Represented
|
|
163
|
+
as seconds since the unix epoch. If None uses the current time.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
The summary protobuffer mentioned above.
|
|
167
|
+
"""
|
|
168
|
+
if end_time_secs is None:
|
|
169
|
+
end_time_secs = time.time()
|
|
170
|
+
|
|
171
|
+
session_end_info = plugin_data_pb2.SessionEndInfo(
|
|
172
|
+
status=status, end_time_secs=end_time_secs
|
|
173
|
+
)
|
|
174
|
+
return _summary(
|
|
175
|
+
metadata.SESSION_END_INFO_TAG,
|
|
176
|
+
plugin_data_pb2.HParamsPluginData(session_end_info=session_end_info),
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _summary(tag, hparams_plugin_data):
|
|
181
|
+
"""Returns a summary holding the given HParamsPluginData message.
|
|
182
|
+
|
|
183
|
+
Helper function.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
tag: string. The tag to use.
|
|
187
|
+
hparams_plugin_data: The HParamsPluginData message to use.
|
|
188
|
+
"""
|
|
189
|
+
summary = tf.compat.v1.Summary()
|
|
190
|
+
tb_metadata = metadata.create_summary_metadata(hparams_plugin_data)
|
|
191
|
+
raw_metadata = tb_metadata.SerializeToString()
|
|
192
|
+
tf_metadata = tf.compat.v1.SummaryMetadata.FromString(raw_metadata)
|
|
193
|
+
summary.value.add(
|
|
194
|
+
tag=tag,
|
|
195
|
+
metadata=tf_metadata,
|
|
196
|
+
tensor=_TF_NULL_TENSOR,
|
|
197
|
+
)
|
|
198
|
+
return summary
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
# Like `metadata.NULL_TENSOR`, but with the TensorFlow version of the
|
|
202
|
+
# proto. Slight kludge needed to expose the `TensorProto` type.
|
|
203
|
+
_TF_NULL_TENSOR = type(tf.make_tensor_proto(0)).FromString(
|
|
204
|
+
metadata.NULL_TENSOR.SerializeToString()
|
|
205
|
+
)
|