baikal.Step.__call__¶
-
Step.__call__(inputs, targets=None, *, compute_func='auto', fit_compute_func='auto', trainable=True)¶ Call the step on input(s) (from previous steps) and generates the output(s) to be used in further steps.
You can call the same step on different inputs and targets to reuse the step (similar to the concept of shared layers and nodes in Keras), and specify a different
compute_func/trainableconfiguration on each call. This is achieved via “ports”: each call creates a new port and associates the given configuration to it. You may access the configuration at each port using theget_*_at(port)methods.- Parameters
inputs – Input(s) to the step.
targets – Target(s) to the step.
compute_func –
Specifies which function must be used when computing the step during the model graph execution. If
"auto"(default), it will use thepredictor thetransformmethod (in that order). If a name string is passed, it will use the method that matches the given name. If a callable is passed, it will use that callable when computing the step.The number of inputs and outputs of the function must match those of the step (this is not checked, but will raise an error during graph execution if there is a mismatch).
scikit-learn classes typically implement a
predictmethod (Estimators) or atransformmethod (Transformers), but with this argument you can, for example, specifypredict_probaas the compute function.fit_compute_func –
Specifies which function must be used when fitting AND computing the step during the model graph execution.
If
"auto"(default), it will use thefit_predictor thefit_transformmethod (in that order) if they are implemented, otherwise it will be disabled. If a name string is passed, it will use the method that matches the given name. If a callable is passed, it will use that callable when fitting the step. IfNoneis passed it will be ignored during graph execution.The number of inputs, outputs and targets, of the function must match those of the step (this is not checked, but will raise an error during graph execution if there is a mismatch).
By default, when a model is fit, the graph engine will for each step 1) execute
fitto fit the step, and then 2) executecompute_functo compute the outputs required by successor steps. If a step specifies afit_compute_func, the graph execution will use that instead to fit and compute the outputs in a single call. This can be useful forleveraging implementations of
fit_transformthat are more efficient than callingfitandtransformseparately,using transductive estimators,
implementing training protocols such as that of stacked classifiers, where the classifier in the first stage might compute out-of-fold predictions.
trainable – Whether the step is trainable (True) or not (False). This flag is only meaningful only for steps with a fit method. Setting
trainable=Falseallows to skip the step when fitting a Model. This is useful if you want to freeze some pre-trained steps.
- Returns
DataPlaceholder – Output(s) of the step.