baikal.Model.__call__

Model.__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/trainable configuration 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 the get_*_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 the predict or the transform method (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 predict method (Estimators) or a transform method (Transformers), but with this argument you can, for example, specify predict_proba as 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 the fit_predict or the fit_transform method (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. If None is 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 fit to fit the step, and then 2) execute compute_func to compute the outputs required by successor steps. If a step specifies a fit_compute_func, the graph execution will use that instead to fit and compute the outputs in a single call. This can be useful for

    1. leveraging implementations of fit_transform that are more efficient than calling fit and transform separately,

    2. using transductive estimators,

    3. 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=False allows 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.