{"record":{"id":"555aed4b7026cdfb","repo":"microsoft/qlib","slug":"this-type-of-input-is-not-supported-555aed","errorCode":null,"errorMessage":"This type of input is not supported","messagePattern":"This type of input is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/model/pytorch_nn.py","lineNumber":442,"sourceCode":"\n\nclass Net(nn.Module):\n    def __init__(self, input_dim, output_dim=1, layers=(256,), act=\"LeakyReLU\"):\n        super(Net, self).__init__()\n\n        layers = [input_dim] + list(layers)\n        dnn_layers = []\n        drop_input = nn.Dropout(0.05)\n        dnn_layers.append(drop_input)\n        hidden_units = input_dim\n        for i, (_input_dim, hidden_units) in enumerate(zip(layers[:-1], layers[1:])):\n            fc = nn.Linear(_input_dim, hidden_units)\n            if act == \"LeakyReLU\":\n                activation = nn.LeakyReLU(negative_slope=0.1, inplace=False)\n            elif act == \"SiLU\":\n                activation = nn.SiLU()\n            else:\n                raise NotImplementedError(f\"This type of input is not supported\")\n            bn = nn.BatchNorm1d(hidden_units)\n            seq = nn.Sequential(fc, bn, activation)\n            dnn_layers.append(seq)\n        drop_input = nn.Dropout(0.05)\n        dnn_layers.append(drop_input)\n        fc = nn.Linear(hidden_units, output_dim)\n        dnn_layers.append(fc)\n        # optimizer  # pylint: disable=W0631\n        self.dnn_layers = nn.ModuleList(dnn_layers)\n        self._weight_init()\n\n    def _weight_init(self):\n        for m in self.modules():\n            if isinstance(m, nn.Linear):\n                nn.init.kaiming_normal_(m.weight, a=0.1, mode=\"fan_in\", nonlinearity=\"leaky_relu\")\n\n    def forward(self, x):\n        cur_output = x","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/model/pytorch_nn.py#L424-L460","documentation":"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().","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use exactly act='LeakyReLU' or act='SiLU' (capitalization matters).","If you need another activation, subclass the model and extend the branch in the layer-building code with your nn activation module.","Verify no trailing whitespace in the YAML string."],"exampleFix":"# before\nkwargs:\n  act: relu\n\n# after\nkwargs:\n  act: LeakyReLU   # or SiLU","handlingStrategy":"validation","validationCode":"act = config[\"act\"]\nassert act in (\"LeakyReLU\", \"SiLU\"), f\"act must be 'LeakyReLU' or 'SiLU' (case-sensitive), got {act!r}\"","typeGuard":"def is_supported_act(act: str) -> bool:\n    return act in (\"LeakyReLU\", \"SiLU\")","tryCatchPattern":"try:\n    model = ModelClass(**kwargs)\nexcept NotImplementedError as e:\n    if \"type of input\" in str(e):\n        raise ValueError(\"act must be exactly 'LeakyReLU' or 'SiLU'\") from e\n    raise","preventionTips":["Remember the activation check is case-sensitive (unlike optimizer names, which are lowercased).","Add a config lint step that whitelists enum-like kwargs before constructing models."],"tags":["qlib","pytorch","activation","config","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}