Creates a new InfeedQueue with the given configuration. The configuration need not be fully specified at creation since it can be modified subsequently by methods that set the values explicitly or infer them from the shapes of inputs. Args: number_of_tuple_elements: the numbe
(self,
number_of_tuple_elements=None,
tuple_types=None,
tuple_shapes=None,
shard_dimensions=None,
name=None)
| 131 | """ |
| 132 | |
| 133 | def __init__(self, |
| 134 | number_of_tuple_elements=None, |
| 135 | tuple_types=None, |
| 136 | tuple_shapes=None, |
| 137 | shard_dimensions=None, |
| 138 | name=None): |
| 139 | """Creates a new InfeedQueue with the given configuration. |
| 140 | |
| 141 | The configuration need not be fully specified at creation since it |
| 142 | can be modified subsequently by methods that set the values |
| 143 | explicitly or infer them from the shapes of inputs. |
| 144 | |
| 145 | Args: |
| 146 | number_of_tuple_elements: the number of Tensors fed atomically through the |
| 147 | queue, must be present unless it can be inferred from other arguments. |
| 148 | tuple_types: if not None, a list of types of the elements of the queue. |
| 149 | tuple_shapes: if not None, a list of shapes of the elements of the queue. |
| 150 | shard_dimensions: if not None, a list of dimensions on which the |
| 151 | elements of the queue should be sharded during automatic |
| 152 | parallelization. |
| 153 | name: the name of the queue. |
| 154 | |
| 155 | Raises: |
| 156 | ValueError: if number_of_tuple_elements <= 0; or |
| 157 | number_of_tuple_arguments, tuple_types, tuple_shapes, and |
| 158 | shard_dimensions are all None; or the length of tuple_types, |
| 159 | tuple_shapes, or shard_dimensions is not equal to |
| 160 | number_of_tuple_elements; or any element of shard_dimensions |
| 161 | can't be converted to a Dimension. |
| 162 | TypeError: if any element of tuple_types or tuple_shapes can't |
| 163 | be converted to a dtype or TensorShape, respectively. |
| 164 | """ |
| 165 | self._frozen = False |
| 166 | self._generated_enqueue_ops = False |
| 167 | self._generated_dequeue_op = False |
| 168 | self._name = "InfeedQueue" if name is None else name |
| 169 | if number_of_tuple_elements is None: |
| 170 | if tuple_types is not None: |
| 171 | number_of_tuple_elements = len(tuple_types) |
| 172 | elif tuple_shapes is not None: |
| 173 | number_of_tuple_elements = len(tuple_shapes) |
| 174 | elif shard_dimensions is not None: |
| 175 | number_of_tuple_elements = len(shard_dimensions) |
| 176 | else: |
| 177 | raise ValueError( |
| 178 | "number of tuple elements cannot be inferred from InfeedQueue " |
| 179 | "constructor") |
| 180 | if number_of_tuple_elements <= 0: |
| 181 | raise ValueError("number_of_tuple_elements %d must be > 0" % |
| 182 | number_of_tuple_elements) |
| 183 | # Make an empty sharding policy for each tuple element. |
| 184 | self._sharding_policies = [ |
| 185 | tpu_sharding.ShardingPolicy() |
| 186 | for _ in xrange(number_of_tuple_elements) |
| 187 | ] |
| 188 | if tuple_types is not None: |
| 189 | self.set_tuple_types(tuple_types) |
| 190 | else: |
no test coverage detected