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

Method _compile_from_inputs

tensorflow/python/keras/engine/training.py:2624–2667  ·  view source on GitHub ↗
(self, all_inputs, target, orig_inputs, orig_target)

Source from the content-addressed store, hash-verified

2622 return processed_inputs, targets, is_dict_inputs
2623
2624 def _compile_from_inputs(self, all_inputs, target, orig_inputs, orig_target):
2625 if target is not None:
2626 # We need to use `y` to set the model targets.
2627 if training_utils.has_tensors(target):
2628 target = training_utils.cast_if_floating_dtype_and_mismatch(
2629 target, self.outputs)
2630 training_utils.validate_input_types(target, orig_target,
2631 allow_dict=False, field_name='target')
2632 if isinstance(target, (list, tuple)):
2633 all_inputs += list(target)
2634 else:
2635 all_inputs.append(target)
2636 # Type check that all inputs are *either* value *or* symbolic.
2637 # TODO(fchollet): this check could be removed in Eager mode?
2638 if any(tensor_util.is_tensor(v) for v in all_inputs):
2639 if not all(tensor_util.is_tensor(v) for v in all_inputs):
2640 raise ValueError('Do not pass inputs that mix Numpy arrays and '
2641 'TensorFlow tensors. '
2642 'You passed: x=' + str(orig_inputs) +
2643 '; y=' + str(orig_target))
2644 is_dataset = isinstance(orig_inputs, (dataset_ops.DatasetV1,
2645 dataset_ops.DatasetV2,
2646 iterator_ops.Iterator))
2647 if is_dataset or context.executing_eagerly():
2648 target_tensors = None
2649 else:
2650 # Handle target tensors if any passed.
2651 if target is not None:
2652 if not isinstance(target, (list, tuple)):
2653 target = [target]
2654 target_tensors = [v for v in target if _is_symbolic_tensor(v)]
2655 else:
2656 target_tensors = None
2657
2658 self.compile(
2659 optimizer=self.optimizer,
2660 loss=self.loss,
2661 metrics=self._compile_metrics,
2662 weighted_metrics=self._compile_weighted_metrics,
2663 loss_weights=self.loss_weights,
2664 target_tensors=target_tensors,
2665 sample_weight_mode=self.sample_weight_mode,
2666 run_eagerly=self.run_eagerly,
2667 experimental_run_tf_function=self._experimental_run_tf_function)
2668
2669 # TODO(omalleyt): Consider changing to a more descriptive function name.
2670 def _set_inputs(self, inputs, outputs=None, training=None):

Callers 2

Calls 7

compileMethod · 0.95
anyFunction · 0.85
allFunction · 0.85
is_tensorMethod · 0.80
executing_eagerlyMethod · 0.80
_is_symbolic_tensorFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected