Skip to content

Conversation

@wchargin
Copy link
Contributor

Summary:
The summaries written by the hparams plugin only contain metadata, which
is conceptually fine but not valid at an implementation level: all
summary Values must contain a tensor. Otherwise, the read paths get
into confusing states where SummaryMetadata can be present for a tag
but actually reading that tag’s Tensors raises KeyError. As of this
patch, hparams summaries include a rank-1 length-0 float tensor. We also
add a read-time dataclass_compat migration for legacy data.

Test Plan:
Calling list_tensors or read_tensors on a MultiplexerDataProvider
now properly returns hparams data. Before this patch, it returned
nothing as the summaries had no data class; if the null tensor backfill
is removed from this patch, it fails with a KeyError.

wchargin-branch: hparams-summary-tensors

Summary:
The summaries written by the hparams plugin only contain metadata, which
is conceptually fine but not valid at an implementation level: all
summary `Value`s must contain a `tensor`. Otherwise, the read paths get
into confusing states where `SummaryMetadata` can be present for a tag
but actually reading that tag’s `Tensors` raises `KeyError`. As of this
patch, hparams summaries include a rank-1 length-0 float tensor. We also
add a read-time `dataclass_compat` migration for legacy data.

Test Plan:
Calling `list_tensors` or `read_tensors` on a `MultiplexerDataProvider`
now properly returns hparams data. Before this patch, it returned
nothing as the summaries had no data class; if the null tensor backfill
is removed from this patch, it fails with a `KeyError`.

wchargin-branch: hparams-summary-tensors
wchargin-branch: hparams-summary-tensors
wchargin-source: c18c31e59f0786f24887949068483618d21bfdc2

# Like `metadata.NULL_TENSOR`, but with the TensorFlow version of the
# proto. Slight kludge needed to expose the `TensorProto` type.
_TF_NULL_TENSOR = type(tf.compat.v1.Summary.Value().tensor).FromString(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO a bit cleaner to do type(tf.make_tensor_proto(0)) for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure: done.

wchargin-branch: hparams-summary-tensors
wchargin-source: a4c4ac8c7ad15588e3fd5f202e196e6befeb9ba4
@wchargin wchargin merged commit 14328a8 into master Mar 17, 2020
@wchargin wchargin deleted the wchargin-hparams-summary-tensors branch March 17, 2020 21:57
@wchargin wchargin mentioned this pull request Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants