{"record":{"id":"ba6b045f0b0bc1f8","repo":"deeplearning4j/deeplearning4j","slug":"error-deserializing-computationgraphconfiguration","errorCode":null,"errorMessage":"Error deserializing ComputationGraphConfiguration - configuration may have a custom layer, vertex or preprocessor, in pre version 1.0.0-beta JSON format.\nModels in legacy format with custom layers should be loaded in 1.0.0-beta to 1.0.0-beta4 and saved again, before loading in the current version of DL4J","messagePattern":"Error deserializing ComputationGraphConfiguration - configuration may have a custom layer, vertex or preprocessor, in pre version 1\\.0\\.0-beta JSON format\\.\nModels in legacy format with custom layers should be loaded in 1\\.0\\.0-beta to 1\\.0\\.0-beta4 and saved again, before loading in the current version of DL4J","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java","lineNumber":240,"sourceCode":"     * @param json the neural net configuration from json\n     * @return {@link ComputationGraphConfiguration}\n     */\n    public static ComputationGraphConfiguration fromJson(String json) {\n        //As per MultiLayerConfiguration.fromJson()\n        ComputationGraphConfiguration conf;\n        try {\n            conf = mapper.readValue(json, ComputationGraphConfiguration.class);\n        } catch (InvalidTypeIdException e){\n            if(e.getMessage().contains(\"@class\")){\n                try{\n                    //JSON may be legacy (1.0.0-alpha or earlier), attempt to load it using old format\n                    return JsonMappers.getLegacyMapper().readValue(json, ComputationGraphConfiguration.class);\n                } catch (InvalidTypeIdException e2){\n                    //Check for legacy custom layers: \"Could not resolve type id 'CustomLayer' as a subtype of [simple type, class org.deeplearning4j.nn.conf.layers.Layer]: known type ids = [Bidirectional, CenterLossOutputLayer, CnnLossLayer, ...\"\n                    //1.0.0-beta5: dropping support for custom layers defined in pre-1.0.0-beta format. Built-in layers from these formats still work\n                    String msg = e2.getMessage();\n                    if(msg != null && msg.contains(\"Could not resolve type id\")) {\n                        throw new RuntimeException(\"Error deserializing ComputationGraphConfiguration - configuration may have a custom \" +\n                                \"layer, vertex or preprocessor, in pre version 1.0.0-beta JSON format.\\nModels in legacy format with custom\" +\n                                \" layers should be loaded in 1.0.0-beta to 1.0.0-beta4 and saved again, before loading in the current version of DL4J\", e);\n                    }\n                    throw new RuntimeException(e2);\n                } catch (IOException e2){\n                    throw new RuntimeException(e2);\n                }\n            }\n            throw new RuntimeException(e);\n        } catch (Exception e) {\n            //Check if this exception came from legacy deserializer...\n            String msg = e.getMessage();\n            if(msg != null && msg.contains(\"legacy\")){\n                throw new RuntimeException(\"Error deserializing ComputationGraphConfiguration - configuration may have a custom \" +\n                        \"layer, vertex or preprocessor, in pre version 1.0.0-alpha JSON format. These layers can be \" +\n                        \"deserialized by first registering them with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Class...)\", e);\n            }\n            throw new RuntimeException(e);","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/conf/ComputationGraphConfiguration.java#L222-L258","documentation":"ComputationGraphConfiguration.fromJson wraps Jackson deserialization failures that stem from custom layers/vertices/preprocessors serialized in the pre-1.0.0-beta JSON format. Since 1.0.0-beta5, DL4J dropped support for deserializing such legacy custom classes directly, so when the type id cannot be resolved it rethrows with a message instructing the user to round-trip the model through DL4J 1.0.0-beta to 1.0.0-beta4.","triggerScenarios":"Calling ComputationGraphConfiguration.fromJson(json) on a JSON config written by a DL4J version older than 1.0.0-beta that contains a custom Layer/GraphVertex/PreProcessor type id unknown to the current mapper, causing InvalidTypeIdException with 'Could not resolve type id'.","commonSituations":"Loading an old .json model config (or checkpoint) containing user-defined layers after upgrading DL4J past 1.0.0-beta4; CI pipelines reading archived legacy models; sharing models between projects with different custom layer sets.","solutions":["Load the model in DL4J 1.0.0-beta through 1.0.0-beta4 and re-save it, then load the re-saved JSON in the current version.","Register the custom classes with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(YourLayer.class) before calling fromJson, if compatible.","Rewrite the custom layer as a built-in or current-format layer and regenerate the configuration JSON."],"exampleFix":"// before\nComputationGraphConfiguration conf = ComputationGraphConfiguration.fromJson(legacyJson); // throws\n// after\nNeuralNetConfiguration.registerLegacyCustomClassesForJSON(MyLegacyLayer.class);\nComputationGraphConfiguration conf = ComputationGraphConfiguration.fromJson(legacyJson);","handlingStrategy":"try-catch","validationCode":"if (json.contains(\"@class\") && usesLegacyCustomLayers) { NeuralNetConfiguration.registerLegacyCustomClassesForJSON(CustomLayersHolder.class); }","typeGuard":null,"tryCatchPattern":"try { return ComputationGraphConfiguration.fromJson(json); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().contains(\"legacy\")) { // round-trip via DL4J 1.0.0-beta..beta4 or register legacy classes } throw e; }","preventionTips":["Re-save all archived models with a recent DL4J version after any upgrade","Keep custom layer classes in the model-loading classpath","Prefer built-in layers in persisted configurations","Track DL4J release notes for dropped legacy JSON support (1.0.0-beta5)"],"tags":["java","json","deserialization","deeplearning4j","legacy-format"],"backgroundTag":"json-unmarshal-failed","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"}