Behave like an identity proxy, but print shape and range of the first few datapoints. Good for debugging. Example: Place it somewhere in your dataflow like .. code-block:: python def create_my_dataflow(): ds = SomeDataSource('path/to/lmdb')
| 702 | |
| 703 | |
| 704 | class PrintData(ProxyDataFlow): |
| 705 | """ |
| 706 | Behave like an identity proxy, but print shape and range of the first few datapoints. |
| 707 | Good for debugging. |
| 708 | |
| 709 | Example: |
| 710 | Place it somewhere in your dataflow like |
| 711 | |
| 712 | .. code-block:: python |
| 713 | |
| 714 | def create_my_dataflow(): |
| 715 | ds = SomeDataSource('path/to/lmdb') |
| 716 | ds = SomeInscrutableMappings(ds) |
| 717 | ds = PrintData(ds, num=2, max_list=2) |
| 718 | return ds |
| 719 | ds = create_my_dataflow() |
| 720 | # other code that uses ds |
| 721 | |
| 722 | When datapoints are taken from the dataflow, it will print outputs like: |
| 723 | |
| 724 | .. code-block:: none |
| 725 | |
| 726 | [0110 09:22:21 @common.py:589] DataFlow Info: |
| 727 | datapoint 0<2 with 4 components consists of |
| 728 | 0: float with value 0.0816501893251 |
| 729 | 1: ndarray:int32 of shape (64,) in range [0, 10] |
| 730 | 2: ndarray:float32 of shape (64, 64) in range [-1.2248, 1.2177] |
| 731 | 3: list of len 50 |
| 732 | 0: ndarray:int32 of shape (64, 64) in range [-128, 80] |
| 733 | 1: ndarray:float32 of shape (64, 64) in range [0.8400, 0.6845] |
| 734 | ... |
| 735 | datapoint 1<2 with 4 components consists of |
| 736 | 0: float with value 5.88252075399 |
| 737 | 1: ndarray:int32 of shape (64,) in range [0, 10] |
| 738 | 2: ndarray:float32 of shape (64, 64) with range [-0.9011, 0.8491] |
| 739 | 3: list of len 50 |
| 740 | 0: ndarray:int32 of shape (64, 64) in range [-70, 50] |
| 741 | 1: ndarray:float32 of shape (64, 64) in range [0.7400, 0.3545] |
| 742 | ... |
| 743 | """ |
| 744 | |
| 745 | def __init__(self, ds, num=1, name=None, max_depth=3, max_list=3): |
| 746 | """ |
| 747 | Args: |
| 748 | ds (DataFlow): input DataFlow. |
| 749 | num (int): number of dataflow points to print. |
| 750 | name (str, optional): name to identify this DataFlow. |
| 751 | max_depth (int, optional): stop output when too deep recursion in sub elements |
| 752 | max_list (int, optional): stop output when too many sub elements |
| 753 | """ |
| 754 | super(PrintData, self).__init__(ds) |
| 755 | self.num = num |
| 756 | self.name = name |
| 757 | self.cnt = 0 |
| 758 | self.max_depth = max_depth |
| 759 | self.max_list = max_list |
| 760 | |
| 761 | def _analyze_input_data(self, entry, k, depth=1, max_depth=3, max_list=3): |
no outgoing calls
no test coverage detected