{"record":{"id":"0d5a977a7225f6db","repo":"deeplearning4j/deeplearning4j","slug":"not-supported-0d5a97","errorCode":null,"errorMessage":"Not supported","messagePattern":"Not supported","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/SoftPlusBp.java","lineNumber":61,"sourceCode":"    }\n\n    @Override\n    public String opName(){\n        return \"softplus_bp\";\n    }\n\n    @Override\n    public List<DataType> calculateOutputDataTypes(List<DataType> dataTypes) {\n        Preconditions\n                .checkArgument(dataTypes != null && dataTypes.size() == 2, \"Expected exactly 2 input datatypes, got %s\", dataTypes);\n        Preconditions.checkArgument(dataTypes.get(0).isFPType() && dataTypes.get(1).isFPType(), \"Input datatypes must be floating point, got %s\", dataTypes);\n\n        return Collections.singletonList(dataTypes.get(0));\n    }\n\n    @Override\n    public List<SDVariable> doDiff(List<SDVariable> f1) {\n        throw new UnsupportedOperationException(\"Not supported\");\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":64,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ops/impl/transforms/gradient/SoftPlusBp.java#L43-L64","documentation":"SoftPlusBp (the backward/backprop op of softplus) is a leaf in the SameDiff differentiation graph: its doDiff() is deliberately unimplemented and always throws UnsupportedOperationException('Not supported'). In ND4J, *_Bp ops exist to propagate gradients, and their own gradient (differentiating the bp op again) is not defined, so the library refuses instead of returning a wrong result. This means second-order differentiation through a softplus bp node is impossible.","triggerScenarios":"Calling SameDiff differencing (e.g. SDVariable.diff(), SameDiff.createGradFunction(), or automatic differentiation) on a graph that contains a SoftPlusBp node, so the framework must compute the gradient OF the softplus_bp op itself.","commonSituations":"Building higher-order gradients (gradient of gradient) over networks using softplus; custom loss functions that differentiate through an explicitly constructed *Bp op; porting models that assume nested autodiff support.","solutions":["Restructure the graph so SoftPlusBp appears only in the forward-of-backward path, never inside a region being differentiated again.","Use the plain SoftPlus op and let SameDiff derive its derivative automatically instead of manually inserting the Bp op.","Override/replace the node with a custom DifferentialFunction whose doDiff is implemented (e.g. via sameDiff.math on primitives)."],"exampleFix":"// before\nSDVariable bp = sameDiff.nn.softPlusBp(input, eps);\nSDVariable loss = secondOrderLoss(bp); // differentiates bp again -> throws\n// after\nSDVariable sp = sameDiff.nn.softPlus(input);            // differentiable primitive\nSDVariable loss = secondOrderLoss(sp);                  // autodiff handles derivative","handlingStrategy":"validation","validationCode":"boolean diffable(SameDiff sd, String varName) {\n    SameDiff fn = sd.getFunction(\"grad\"); // or inspect ops before differentiating\n    return sd.ops().stream().noneMatch(o -> o instanceof org.nd4j.linalg.api.ops.impl.transforms.gradient.SoftPlusBp);\n}","typeGuard":null,"tryCatchPattern":"try {\n    sd.createGradFunction();\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"Not supported\")) {\n        // rebuild graph using plain SoftPlus instead of SoftPlusBp\n    } else throw e;\n}","preventionTips":["Never place explicit *_Bp ops inside regions you intend to differentiate again.","Prefer primitive differentiable ops (softplus) over hand-inserted backward ops in forward graphs.","When doing second-order autodiff, audit the graph's op list first."],"tags":["nd4j","samediff","autodiff","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}