How to use the tensorboard.util.tb_logging function in tensorboard

To help you get started, we’ve selected a few tensorboard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / tensorboard / tensorboard / plugins / beholder / video_writing.py View on Github external
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import abc
import os
import six
import subprocess
import time

import numpy as np
import tensorflow as tf
from tensorboard.plugins.beholder import im_util
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()


class VideoWriter(object):
    """Video file writer that can use different output types.

    Each VideoWriter instance writes video files to a specified
    directory, using the first available VideoOutput from the provided
    list.
    """

    def __init__(self, directory, outputs):
        self.directory = directory
        # Filter to the available outputs
        self.outputs = [out for out in outputs if out.available()]
        if not self.outputs:
            raise IOError("No available video outputs")
github tensorflow / tensorboard / tensorboard / uploader / logdir_loader.py View on Github external
# ==============================================================================
"""Loader for event file data for an entire TensorBoard log directory."""

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

import collections
import os

from tensorboard.backend.event_processing import directory_watcher
from tensorboard.backend.event_processing import io_wrapper
from tensorboard.util import tb_logging


logger = tb_logging.get_logger()


class LogdirLoader(object):
    """Loader for a root log directory, maintaining multiple DirectoryLoaders.

    This class takes a root log directory and a factory for DirectoryLoaders, and
    maintains one DirectoryLoader per "logdir subdirectory" of the root logdir.

    Note that this class is not thread-safe.
    """

    def __init__(self, logdir, directory_loader_factory):
        """Constructs a new LogdirLoader.

        Args:
          logdir: The root log directory to load from.
github tensorflow / tensorboard / tensorboard / main.py View on Github external
#   https://github.com/tensorflow/tensorboard/issues/1225
# This must be set before the first import of tensorflow.
os.environ["GCS_READ_CACHE_DISABLED"] = "1"


import sys

from tensorboard import default
from tensorboard import program
from tensorboard.compat import tf
from tensorboard.plugins import base_plugin
from tensorboard.uploader import uploader_main
from tensorboard.util import tb_logging


logger = tb_logging.get_logger()


def run_main():
    """Initializes flags and calls main()."""
    program.setup_environment()

    if getattr(tf, "__version__", "stub") == "stub":
        print(
            "TensorFlow installation not found - running with reduced feature set.",
            file=sys.stderr,
        )

    tensorboard = program.TensorBoard(
        default.get_plugins() + default.get_dynamic_plugins(),
        program.get_default_assets_zip_provider(),
        subcommands=[uploader_main.UploaderSubcommand()],
github tensorflow / tensorboard / tensorboard / plugins / debugger / debugger_plugin_loader.py View on Github external
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import sys

import six
from werkzeug import wrappers

from tensorboard.backend import http_util
from tensorboard.plugins import base_plugin
from tensorboard.plugins.debugger import constants
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()


class InactiveDebuggerPlugin(base_plugin.TBPlugin):
    """A placeholder debugger plugin used when no grpc port is specified."""

    plugin_name = constants.DEBUGGER_PLUGIN_NAME

    def __init__(self):
        pass

    def is_active(self):
        return False

    def frontend_metadata(self):
        return base_plugin.FrontendMetadata(
            element_name="tf-debugger-dashboard"
github tensorflow / tensorboard / tensorboard / plugins / debugger / debugger_server_lib.py View on Github external
import re
import threading
import time

import tensorflow as tf
from tensorflow.python.debug.lib import grpc_debug_server

from tensorboard.plugins.debugger import constants
from tensorboard.plugins.debugger import (
    events_writer_manager as events_writer_manager_lib,
)
from tensorboard.plugins.debugger import numerics_alert
from tensorboard.util import tb_logging
from tensorboard.util import tensor_util

logger = tb_logging.get_logger()


class DebuggerDataStreamHandler(
    grpc_debug_server.EventListenerBaseStreamHandler
):
    """Implementation of stream handler for debugger data.

    Each instance of this class is created by a DebuggerDataServer upon a
    gRPC stream established between the debugged Session::Run() invocation in
    TensorFlow core runtime and the DebuggerDataServer instance.

    Each instance of this class does the following:
      1) receives a core metadata Event proto during its constructor call.
      2) receives GraphDef Event proto(s) through its on_graph_event method.
      3) receives tensor value Event proto(s) through its on_value_event method.
    """
github tensorflow / tensorboard / tensorboard / plugins / image / images_demo.py View on Github external
from absl import app
from absl import logging
import contextlib
import os.path
import textwrap

from six.moves import urllib
from six.moves import xrange  # pylint: disable=redefined-builtin

import tensorflow as tf

from tensorboard.compat.proto import config_pb2
from tensorboard.plugins.image import summary as image_summary
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()

# Directory into which to write tensorboard data.
LOGDIR = "/tmp/images_demo"

# pylint: disable=line-too-long
IMAGE_URL = r"https://upload.wikimedia.org/wikipedia/commons/f/f0/Valve_original_%281%29.PNG"
# pylint: enable=line-too-long
IMAGE_CREDIT = textwrap.dedent(
    """\
    Photo by Wikipedia contributor [User:Tauraloke], distributed under
    CC-BY-SA 3.0. [Source].

    [User:Tauraloke]: https://commons.wikimedia.org/wiki/User:Tauraloke
    [Source]: https://commons.wikimedia.org/wiki/File:Valve_original_(1).PNG
    """
)
github tensorflow / tensorboard / tensorboard / backend / security_validator.py View on Github external
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import collections

from werkzeug import wrappers
from werkzeug.datastructures import Headers
from werkzeug import http

from tensorboard.util import tb_logging

# Loosely follow vocabulary from https://www.w3.org/TR/CSP/#framework-directives.
Directive = collections.namedtuple("Directive", ["name", "value"])

logger = tb_logging.get_logger()

_HTML_MIME_TYPE = "text/html"
_CSP_DEFAULT_SRC = "default-src"
# Whitelist of allowed CSP violations.
_CSP_IGNORE = {
    # Allow TensorBoard to be iframed.
    "frame-ancestors": ["*"],
    # Polymer-based code uses unsafe-inline.
    "style-src": ["'unsafe-inline'", "data:"],
    # Used in canvas
    "img-src": ["blob:", "data:"],
    # Used by numericjs.
    # TODO(stephanwlee): remove it eventually.
    "script-src": ["'unsafe-eval'"],
}
github tensorflow / tensorboard / tensorboard / plugins / audio / metadata.py View on Github external
# 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.
# ==============================================================================
"""Internal information about the audio plugin."""

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

from tensorboard.compat.proto import summary_pb2
from tensorboard.plugins.audio import plugin_data_pb2
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()

PLUGIN_NAME = "audio"

# The most recent value for the `version` field of the `AudioPluginData`
# proto.
PROTO_VERSION = 0

# Expose the `Encoding` enum constants.
Encoding = plugin_data_pb2.AudioPluginData.Encoding


def create_summary_metadata(display_name, description, encoding):
    """Create a `SummaryMetadata` proto for audio plugin data.

    Returns:
      A `SummaryMetadata` protobuf object.
github tensorflow / tensorboard / tensorboard / plugins / core / core_plugin.py View on Github external
import gzip
import math
import mimetypes
import os
import zipfile

import six
from werkzeug import utils
from werkzeug import wrappers

from tensorboard import plugin_util
from tensorboard.backend import http_util
from tensorboard.plugins import base_plugin
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()


# If no port is specified, try to bind to this port. See help for --port
# for more details.
DEFAULT_PORT = 6006


class CorePlugin(base_plugin.TBPlugin):
    """Core plugin for TensorBoard.

    This plugin serves runs, configuration data, and static assets. This
    plugin should always be present in a TensorBoard WSGI application.
    """

    plugin_name = "core"
github tensorflow / tensorboard / tensorboard / plugins / graph / graphs_plugin.py View on Github external
from tensorboard import plugin_util
from tensorboard.backend import http_util
from tensorboard.backend import process_graph
from tensorboard.backend.event_processing import (
    plugin_event_accumulator as event_accumulator,
)
from tensorboard.compat.proto import config_pb2
from tensorboard.compat.proto import graph_pb2
from tensorboard.data import provider
from tensorboard.plugins import base_plugin
from tensorboard.plugins.graph import graph_util
from tensorboard.plugins.graph import keras_util
from tensorboard.plugins.graph import metadata
from tensorboard.util import tb_logging

logger = tb_logging.get_logger()

# The Summary API is implemented in TensorFlow because it uses TensorFlow internal APIs.
# As a result, this SummaryMetadata is a bit unconventional and uses non-public
# hardcoded name as the plugin name. Please refer to link below for the summary ops.
# https://github.com/tensorflow/tensorflow/blob/11f4ecb54708865ec757ca64e4805957b05d7570/tensorflow/python/ops/summary_ops_v2.py#L757
_PLUGIN_NAME_RUN_METADATA = "graph_run_metadata"
# https://github.com/tensorflow/tensorflow/blob/11f4ecb54708865ec757ca64e4805957b05d7570/tensorflow/python/ops/summary_ops_v2.py#L788
_PLUGIN_NAME_RUN_METADATA_WITH_GRAPH = "graph_run_metadata_graph"
# https://github.com/tensorflow/tensorflow/blob/565952cc2f17fdfd995e25171cf07be0f6f06180/tensorflow/python/ops/summary_ops_v2.py#L825
_PLUGIN_NAME_KERAS_MODEL = "graph_keras_model"


class GraphsPlugin(base_plugin.TBPlugin):
    """Graphs Plugin for TensorBoard."""

    plugin_name = metadata.PLUGIN_NAME