MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _set_input_attrs

Method _set_input_attrs

tensorflow/python/keras/engine/training.py:2717–2755  ·  view source on GitHub ↗

Sets attributes related to the inputs of the Model.

(self, inputs)

Source from the content-addressed store, hash-verified

2715
2716 @trackable.no_automatic_dependency_tracking
2717 def _set_input_attrs(self, inputs):
2718 """Sets attributes related to the inputs of the Model."""
2719 if self.inputs:
2720 raise ValueError('Model inputs are already set.')
2721
2722 if self.__class__.__name__ == 'Sequential' and not self.built:
2723 if tensor_util.is_tensor(inputs):
2724 input_shape = (None,) + tuple(inputs.shape.as_list()[1:])
2725 elif isinstance(inputs, tensor_shape.TensorShape):
2726 input_shape = (None,) + tuple(inputs.as_list()[1:])
2727 elif isinstance(inputs, dict):
2728 # We assert that the first layer is a FeatureLayer.
2729 if not training_utils.is_feature_layer(self.layers[0]):
2730 raise ValueError('Passing a dictionary input to a Sequential Model '
2731 'which doesn\'t have FeatureLayer as the first layer'
2732 ' is an error.')
2733 input_shape = (None,)
2734 else:
2735 input_shape = (None,) + tuple(inputs.shape[1:])
2736 self._build_input_shape = input_shape
2737
2738 # On-the-fly setting of symbolic model inputs (either by using the tensor
2739 # provided, or by creating a placeholder if Numpy data was provided).
2740 model_inputs = training_utils.ModelInputs(inputs)
2741 inputs = model_inputs.get_symbolic_inputs()
2742 self.inputs = model_inputs.get_symbolic_inputs(return_single_as_list=True)
2743 self.input_names = model_inputs.get_input_names()
2744
2745 self._feed_inputs = []
2746 self._feed_input_names = []
2747 self._feed_input_shapes = []
2748
2749 for k, v in model_inputs.as_dict():
2750 if K.is_placeholder(v):
2751 self._feed_input_names.append(k)
2752 self._feed_inputs.append(v)
2753 self._feed_input_shapes.append(K.int_shape(v))
2754
2755 return inputs
2756
2757 @trackable.no_automatic_dependency_tracking
2758 def _set_output_attrs(self, outputs):

Callers 1

_set_inputsMethod · 0.95

Calls 7

get_symbolic_inputsMethod · 0.95
get_input_namesMethod · 0.95
as_dictMethod · 0.95
tupleFunction · 0.85
is_tensorMethod · 0.80
as_listMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected