MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / get_input_signature

Method get_input_signature

tensorpack/train/model_desc.py:30–45  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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):

Callers 9

input_namesMethod · 0.95
__init__Method · 0.80
launch_train_with_configFunction · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 4

inputsMethod · 0.95
TensorSpecClass · 0.85
get_op_tensor_nameFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected