(cls, tensor, name=None)
| 50 | |
| 51 | @classmethod |
| 52 | def from_tensor(cls, tensor, name=None): |
| 53 | if isinstance(tensor, ops.EagerTensor): |
| 54 | return TensorSpec(tensor.shape, tensor.dtype, name) |
| 55 | elif isinstance(tensor, ops.Tensor): |
| 56 | return TensorSpec(tensor.shape, tensor.dtype, name or tensor.op.name) |
| 57 | else: |
| 58 | raise ValueError("`tensor` should be a tf.Tensor") |
| 59 | |
| 60 | @property |
| 61 | def shape(self): |