Returns: A list of :class:`tf.TensorSpec`, which describes the inputs of this model. The result is cached for each instance of :class:`ModelDescBase`.
(self)
| 28 | |
| 29 | @memoized_method |
| 30 | def get_input_signature(self): |
| 31 | """ |
| 32 | Returns: |
| 33 | A list of :class:`tf.TensorSpec`, which describes the inputs of this model. |
| 34 | The result is cached for each instance of :class:`ModelDescBase`. |
| 35 | """ |
| 36 | with tf.Graph().as_default() as G: # create these placeholder in a temporary graph |
| 37 | inputs = self.inputs() |
| 38 | assert isinstance(inputs, (list, tuple)), \ |
| 39 | "ModelDesc.inputs() should return a list of tf.TensorSpec objects! Got {} instead.".format(str(inputs)) |
| 40 | if isinstance(inputs[0], tf.Tensor): |
| 41 | for p in inputs: |
| 42 | assert "Placeholder" in p.op.type, \ |
| 43 | "inputs() have to return TensorSpec or placeholders! Found {} instead.".format(p) |
| 44 | assert p.graph == G, "Placeholders returned by inputs() should be created inside inputs()!" |
| 45 | return [TensorSpec(shape=p.shape, dtype=p.dtype, name=get_op_tensor_name(p.name)[0]) for p in inputs] |
| 46 | |
| 47 | @property |
| 48 | def input_names(self): |
no test coverage detected