예제 #1
0
    def log_histogram(
        self, name, values, bins, max_bins=None, step=None, timestamp=None
    ):
        event_value = events_processors.histogram(
            values=values, bins=bins, max_bins=max_bins
        )

        if event_value == UNKNOWN:
            return

        logged_event = LoggedEventSpec(
            name=name,
            kind=V1ArtifactKind.HISTOGRAM,
            event=V1Event(timestamp=timestamp, step=step, histogram=event_value),
        )
        self._event_logger.add_event(logged_event)
예제 #2
0
파일: run.py 프로젝트: yangjun1994/polyaxon
    def log_histogram(self,
                      name,
                      values,
                      bins,
                      max_bins=None,
                      step=None,
                      timestamp=None):
        """Logs a histogram.

        ```python
        >>> log_histogram(name="histo", values=np.arange(np.prod((1024,)), dtype=float).reshape((1024,)), bins="auto", step=1)  # noqa
        ```

        Args:
            name: str, name
            values: np.array
            bins: int or str
            max_bins: int, optional
            step: int, optional
            timestamp: datetime, optional
        """
        self._log_has_events()

        event_value = events_processors.histogram(values=values,
                                                  bins=bins,
                                                  max_bins=max_bins)

        if event_value == UNKNOWN:
            return

        logged_event = LoggedEventSpec(
            name=name,
            kind=V1ArtifactKind.HISTOGRAM,
            event=V1Event.make(timestamp=timestamp,
                               step=step,
                               histogram=event_value),
        )
        self._event_logger.add_event(logged_event)
예제 #3
0
 def test_empty_input(self):
     print("expect error here:")
     with pytest.raises(Exception):
         histogram("dummy", np.ndarray(0), "tensorflow")
예제 #4
0
 def test_list_input(self):
     with pytest.raises(Exception):
         histogram("dummy", [1, 3, 4, 5, 6], "tensorflow")
예제 #5
0
 def test_histogram_doane(self):
     event = histogram(tensor_np(shape=(1024, )), bins="doane", max_bins=5)
     assert event.values is not None
     assert event.counts is not None
예제 #6
0
 def test_histogram_auto(self):
     event = histogram(values=tensor_np(shape=(1024, )),
                       bins="auto",
                       max_bins=5)
     assert event.values is not None
     assert event.counts is not None