SamplerCell stores each value of a Sampler.
| 335 | |
| 336 | |
| 337 | class SamplerCell(object): |
| 338 | """SamplerCell stores each value of a Sampler.""" |
| 339 | |
| 340 | def __init__(self, cell): |
| 341 | """Creates a new SamplerCell. |
| 342 | |
| 343 | Args: |
| 344 | cell: A c pointer of TFE_MonitoringSamplerCell. |
| 345 | """ |
| 346 | self._cell = cell |
| 347 | |
| 348 | def add(self, value): |
| 349 | """Atomically add a sample. |
| 350 | |
| 351 | Args: |
| 352 | value: float value. |
| 353 | """ |
| 354 | pywrap_tensorflow.TFE_MonitoringSamplerCellAdd(self._cell, value) |
| 355 | |
| 356 | def value(self): |
| 357 | """Retrieves the current distribution of samples. |
| 358 | |
| 359 | Returns: |
| 360 | A HistogramProto describing the distribution of samples. |
| 361 | """ |
| 362 | with c_api_util.tf_buffer() as buffer_: |
| 363 | pywrap_tensorflow.TFE_MonitoringSamplerCellValue(self._cell, buffer_) |
| 364 | proto_data = pywrap_tensorflow.TF_GetBuffer(buffer_) |
| 365 | histogram_proto = summary_pb2.HistogramProto() |
| 366 | histogram_proto.ParseFromString(compat.as_bytes(proto_data)) |
| 367 | return histogram_proto |
| 368 | |
| 369 | |
| 370 | class Buckets(object): |