def generate_event(self, values):
        """
        Method for generating scalar event.

        Args:
            values (dict): A dict contains:
                {
                    wall_time (float): Timestamp.
                    step (int): Train step.
                    value (float): Scalar value.
                    tag (str): Tag name.
                }


       Returns:
            summary_pb2.Event.

        """
        scalar_event = summary_pb2.Event()
        scalar_event.wall_time = values.get('wall_time')
        scalar_event.step = values.get('step')

        value = scalar_event.summary.value.add()
        value.tag = values.get('tag')
        value.scalar_value = values.get('value')

        return scalar_event
    def generate_event(self, values):
        """
        Method for generating tensor event.

        Args:
            values (dict): A dict contains:
                {
                    wall_time (float): Timestamp.
                    step (int): Train step.
                    value (float): Tensor value.
                    tag (str): Tag name.
                }

       Returns:
            summary_pb2.Event.

        """
        tensor_event = summary_pb2.Event()
        tensor_event.wall_time = values.get('wall_time')
        tensor_event.step = values.get('step')

        value = tensor_event.summary.value.add()
        value.tag = values.get('tag')
        tensor = values.get('value')

        value.tensor.dims[:] = tensor.get('dims')
        value.tensor.data_type = tensor.get('data_type')
        value.tensor.float_data[:] = tensor.get('float_data')
        print(tensor.get('float_data'))

        return tensor_event
예제 #3
0
    def generate_event(self, values):
        """
        Method for generating image event.

        Args:
            values (dict): A dict contains:
                {
                    wall_time (float): Timestamp.
                    step (int): Train step.
                    image (np.array): Pixels tensor.
                    tag (str): Tag name.
                }

        Returns:
            summary_pb2.Event.

        """

        image_event = summary_pb2.Event()
        image_event.wall_time = values.get('wall_time')
        image_event.step = values.get('step')

        height, width, channel, image_string = self._get_image_string(
            values.get('image'))
        value = image_event.summary.value.add()
        value.tag = values.get('tag')
        value.image.height = height
        value.image.width = width
        value.image.colorspace = channel
        value.image.encoded_image = image_string

        return image_event
예제 #4
0
def create_lineage_info(train_event_dict, eval_event_dict, dataset_event_dict):
    """
    Create parsed lineage info tuple.

    Args:
        train_event_dict (Union[dict, None]): The dict of train event.
        eval_event_dict (Union[dict, None]): The dict of evaluation event.
        dataset_event_dict (Union[dict, None]): The dict of dataset graph event.

    Returns:
        namedtuple, parsed lineage info.
    """
    if train_event_dict is not None:
        train_event = summary_pb2.Event()
        ParseDict(train_event_dict, train_event)
    else:
        train_event = None

    if eval_event_dict is not None:
        eval_event = summary_pb2.Event()
        ParseDict(eval_event_dict, eval_event)
    else:
        eval_event = None

    if dataset_event_dict is not None:
        dataset_event = summary_pb2.Event()
        ParseDict(dataset_event_dict, dataset_event)
    else:
        dataset_event = None

    lineage_info = LineageInfo(
        train_lineage=train_event,
        eval_lineage=eval_event,
        dataset_graph=dataset_event,
    )
    return lineage_info
    def generate_event(self, values):
        """
        Method for generating graph event.

        Args:
            values (dict): Graph values. e.g. {'graph': graph_dict}.

        Returns:
            summary_pb2.Event.

        """
        graph_json = {
            'wall_time': time.time(),
            'graph_def': values.get('graph'),
        }
        graph_event = json_format.Parse(json.dumps(graph_json), summary_pb2.Event())

        return graph_event
예제 #6
0
    def generate_event(self, values):
        """
        Method for generating histogram event.

        Args:
            values (dict): A dict contains:
                {
                    wall_time (float): Timestamp.
                    step (int): Train step.
                    value (float): Histogram value.
                    tag (str): Tag name.
                }

       Returns:
            summary_pb2.Event.

        """
        histogram_event = summary_pb2.Event()
        histogram_event.wall_time = values.get('wall_time')
        histogram_event.step = values.get('step')

        value = histogram_event.summary.value.add()
        value.tag = values.get('tag')

        buckets = values.get('buckets')
        for bucket in buckets:
            left, width, count = bucket
            bucket = value.histogram.buckets.add()
            bucket.left = left
            bucket.width = width
            bucket.count = count

        value.histogram.min = values.get("min", -1)
        value.histogram.max = values.get("max", -1)

        return histogram_event