microsoft/qlib · error · NotImplementedError

This type of input is not supported

Error message

This type of input is not supported

What it means

Raised in the DNN modeling helper (qlib/contrib/model/pytorch_nn.py:442, the module building fully connected layers, e.g. for ADD and similar models) when the act (activation) parameter is neither 'LeakyReLU' nor 'SiLU'. Each hidden Linear layer is wrapped as Sequential(fc, BatchNorm1d, activation); only those two activation strings are recognized, and note the check is case-sensitive with no .lower().

Source

Thrown at qlib/contrib/model/pytorch_nn.py:442


class Net(nn.Module):
    def __init__(self, input_dim, output_dim=1, layers=(256,), act="LeakyReLU"):
        super(Net, self).__init__()

        layers = [input_dim] + list(layers)
        dnn_layers = []
        drop_input = nn.Dropout(0.05)
        dnn_layers.append(drop_input)
        hidden_units = input_dim
        for i, (_input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):
            fc = nn.Linear(_input_dim, hidden_units)
            if act == "LeakyReLU":
                activation = nn.LeakyReLU(negative_slope=0.1, inplace=False)
            elif act == "SiLU":
                activation = nn.SiLU()
            else:
                raise NotImplementedError(f"This type of input is not supported")
            bn = nn.BatchNorm1d(hidden_units)
            seq = nn.Sequential(fc, bn, activation)
            dnn_layers.append(seq)
        drop_input = nn.Dropout(0.05)
        dnn_layers.append(drop_input)
        fc = nn.Linear(hidden_units, output_dim)
        dnn_layers.append(fc)
        # optimizer  # pylint: disable=W0631
        self.dnn_layers = nn.ModuleList(dnn_layers)
        self._weight_init()

    def _weight_init(self):
        for m in self.modules():
            if isinstance(m, nn.Linear):
                nn.init.kaiming_normal_(m.weight, a=0.1, mode="fan_in", nonlinearity="leaky_relu")

    def forward(self, x):
        cur_output = x

View on GitHub (pinned to 79633dd950)

Solutions

  1. Use exactly act='LeakyReLU' or act='SiLU' (capitalization matters).
  2. If you need another activation, subclass the model and extend the branch in the layer-building code with your nn activation module.
  3. Verify no trailing whitespace in the YAML string.

Example fix

# before
kwargs:
  act: relu

# after
kwargs:
  act: LeakyReLU   # or SiLU
Defensive patterns

Strategy: validation

Validate before calling

act = config["act"]
assert act in ("LeakyReLU", "SiLU"), f"act must be 'LeakyReLU' or 'SiLU' (case-sensitive), got {act!r}"

Type guard

def is_supported_act(act: str) -> bool:
    return act in ("LeakyReLU", "SiLU")

Try / catch

try:
    model = ModelClass(**kwargs)
except NotImplementedError as e:
    if "type of input" in str(e):
        raise ValueError("act must be exactly 'LeakyReLU' or 'SiLU'") from e
    raise

Prevention

When it happens

Trigger: Passing act='relu', act='ReLU', act='tanh', or act='leakyrelu' (wrong case) to the model constructor that builds these dnn_layers; the error fires during __init__/model construction, before any training.

Common situations: Assuming lowercase 'relu' works because other qlib params (optimizer names) are lowercased; config copied from a Keras-style example using 'relu'; typo in the activation key of a YAML workflow.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/555aed4b7026cdfb. Report an issue: GitHub.