Creates a DatasetV2 object. This is a difference between DatasetV1 and DatasetV2. DatasetV1 does not take anything in its constructor whereas in the DatasetV2, we expect subclasses to create a variant_tensor and pass it in to the super() call. Args: variant_tensor: A DT_VARIA
(self, variant_tensor)
| 132 | """ |
| 133 | |
| 134 | def __init__(self, variant_tensor): |
| 135 | """Creates a DatasetV2 object. |
| 136 | |
| 137 | This is a difference between DatasetV1 and DatasetV2. DatasetV1 does not |
| 138 | take anything in its constructor whereas in the DatasetV2, we expect |
| 139 | subclasses to create a variant_tensor and pass it in to the super() call. |
| 140 | |
| 141 | Args: |
| 142 | variant_tensor: A DT_VARIANT tensor that represents the dataset. |
| 143 | """ |
| 144 | self._variant_tensor_attr = variant_tensor |
| 145 | weak_self = weakref.proxy(self) |
| 146 | self._variant_tracker = self._track_trackable( |
| 147 | _VariantTracker( |
| 148 | self._variant_tensor, |
| 149 | # _trace_variant_creation only works when executing eagerly, so we |
| 150 | # don't want to run it immediately. We also want the _VariantTracker |
| 151 | # to have a weak reference to the Dataset to avoid creating |
| 152 | # reference cycles and making work for the garbage collector. |
| 153 | lambda: weak_self._trace_variant_creation()()), # pylint: disable=unnecessary-lambda,protected-access |
| 154 | name="_variant_tracker") |
| 155 | self._graph_attr = ops.get_default_graph() |
| 156 | |
| 157 | @property |
| 158 | def _variant_tensor(self): |