Exemplo n.º 1
0
    def test_int_gauge(self):
        gauge = monitoring.IntGauge('test/gauge', 'test gauge')
        gauge.get_cell().set(1)
        self.assertEqual(gauge.get_cell().value(), 1)
        gauge.get_cell().set(5)
        self.assertEqual(gauge.get_cell().value(), 5)

        gauge1 = monitoring.IntGauge('test/gauge1', 'test gauge1', 'label1')
        gauge1.get_cell('foo').set(2)
        self.assertEqual(gauge1.get_cell('foo').value(), 2)
Exemplo n.º 2
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Helper functions for the Keras implementations of models."""

import multiprocessing
import os
import time

import tensorflow as tf
from absl import logging
from tensorflow.python.eager import monitoring

global_batch_size_gauge = monitoring.IntGauge(
    '/tensorflow/training/global_batch_size', 'TF training global batch size')

first_batch_time_gauge = monitoring.IntGauge(
    '/tensorflow/training/first_batch',
    'TF training start/end time for first batch (unix epoch time in us.',
    'type')

first_batch_start_time = first_batch_time_gauge.get_cell('start')
first_batch_end_time = first_batch_time_gauge.get_cell('end')


class BatchTimestamp(object):
    """A structure to store batch time stamp."""
    def __init__(self, batch_index, timestamp):
        self.batch_index = batch_index
        self.timestamp = timestamp
Exemplo n.º 3
0
"""Helper functions for the Keras implementations of models."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import multiprocessing
import os
import time

from absl import logging
import tensorflow as tf

from tensorflow.python.eager import monitoring

global_batch_size_gauge = monitoring.IntGauge(
    '/tensorflow/training/global_batch_size', 'TF training global batch size')


class BatchTimestamp(object):
    """A structure to store batch time stamp."""
    def __init__(self, batch_index, timestamp):
        self.batch_index = batch_index
        self.timestamp = timestamp

    def __repr__(self):
        return "'BatchTimestamp<batch_index: {}, timestamp: {}>'".format(
            self.batch_index, self.timestamp)


class TimeHistory(tf.keras.callbacks.Callback):
    """Callback for Keras models."""
Exemplo n.º 4
0
    'Counter for number of conversion attempts.')

_counter_conversion_success = monitoring.Counter(
    '/tensorflow/lite/convert/success',
    'Counter for number of successful conversions.')

_gauge_conversion_params = monitoring.StringGauge(
    '/tensorflow/lite/convert/params',
    'Gauge for keeping conversion parameters.', 'name')

_gauge_conversion_errors = monitoring.StringGauge(
    '/tensorflow/lite/convert/errors',
    'Gauge for collecting conversion errors. The value represents the error '
    'message.', 'component', 'subcomponent', 'op_name', 'error_code')

_gauge_conversion_latency = monitoring.IntGauge(
    '/tensorflow/lite/convert/latency', 'Conversion latency in ms.')


class TFLiteMetrics(metrics_interface.TFLiteMetricsInterface):
    """TFLite metrics helper for prod (borg) environment.

  Attributes:
    model_hash: A string containing the hash of the model binary.
    model_path: A string containing the path of the model for debugging
      purposes.
  """
    def __init__(self,
                 model_hash: Optional[Text] = None,
                 model_path: Optional[Text] = None) -> None:
        del self  # Temporarily removing self until parameter logic is implemented.
        if model_hash and not model_path or not model_hash and model_path:
Exemplo n.º 5
0
"""Helper functions for the Keras implementations of models."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import multiprocessing
import os
import time

from absl import logging
import tensorflow as tf

from tensorflow.python.eager import monitoring

global_batch_size_gauge = monitoring.IntGauge(
    '/tensorflow/training/global_batch_size', 'TF training global batch size')

first_batch_start_time = monitoring.IntGauge(
    '/tensorflow/training/first_batch_start',
    'TF training start time (unix epoch time in us.')


class BatchTimestamp(object):
    """A structure to store batch time stamp."""
    def __init__(self, batch_index, timestamp):
        self.batch_index = batch_index
        self.timestamp = timestamp

    def __repr__(self):
        return "'BatchTimestamp<batch_index: {}, timestamp: {}>'".format(
            self.batch_index, self.timestamp)