def compute_and_check_summary_pb(self, name='nemo', data=None, bucket_count=None, display_name=None, description=None, data_tensor=None, bucket_count_tensor=None, feed_dict=None): """Use both `op` and `pb` to get a summary, asserting equality. Returns: a `Summary` protocol buffer """ if data is None: data = self.gaussian if data_tensor is None: data_tensor = tf.constant(data) if bucket_count_tensor is None: bucket_count_tensor = bucket_count op = summary.op(name, data_tensor, bucket_count=bucket_count_tensor, display_name=display_name, description=description) pb = summary.pb(name, data, bucket_count=bucket_count, display_name=display_name, description=description) pb_via_op = self.pb_via_op(op, feed_dict=feed_dict) self.assertProtoEquals(pb, pb_via_op) return pb
def test_histogram(self): old_event = event_pb2.Event() old_event.step = 123 old_event.wall_time = 456.75 histogram_pb = histogram_summary.pb( "foo", [1.0, 2.0, 3.0, 4.0], bucket_count=12, display_name="bar", description="baz", ) old_event.summary.ParseFromString(histogram_pb.SerializeToString()) new_events = self._migrate_event(old_event) self.assertLen(new_events, 1) self.assertLen(new_events[0].summary.value, 1) value = new_events[0].summary.value[0] tensor = tensor_util.make_ndarray(value.tensor) self.assertEqual(tensor.shape, (12, 3)) np.testing.assert_array_equal( tensor, tensor_util.make_ndarray(histogram_pb.value[0].tensor)) self.assertEqual(value.metadata.data_class, summary_pb2.DATA_CLASS_TENSOR) self.assertEqual( value.metadata.plugin_data.plugin_name, histogram_metadata.PLUGIN_NAME, )
def histogram(self, *args, **kwargs): # Map new name to the old name. if "buckets" in kwargs: kwargs["bucket_count"] = kwargs.pop("buckets") return summary.pb(*args, **kwargs)
def histogram(self, *args, **kwargs): # Map new name to the old name. if 'buckets' in kwargs: kwargs['bucket_count'] = kwargs.pop('buckets') return summary.pb(*args, **kwargs)