New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load existing computation graph. #6552

Closed
ChadiOm opened this Issue Oct 9, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@ChadiOm
Copy link

ChadiOm commented Oct 9, 2018

Hello everyone.

My code is very simple :

<
ComputationGraph computationGraph = ModelSerializer.restoreComputationGraph (new File(path2Net));

path2Net refers to the path where my .zip is located. The .zip contains a JSON file edited in version 1.0.0-alpha.

In version 1.0.0-alpha, everything worked well. I upgraded my version to 1.0.0-beta2 and I have the following error message :

"Error deserializing ComputationGraphConfiguration - configuration may have a custom layer, vertex or preprocessor, in pre version 1.0.0-alpha JSON format. These layers can be deserialized by first registering them with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Class...)"

Please someone can help me ?

Thanx

@AlexDBlack

This comment has been minimized.

Copy link
Member

AlexDBlack commented Oct 9, 2018

Well, does this network have a custom layer or vertex?
If so, then follow the instructions in the error message.
So, as per the error, call

NeuralNetConfiguration.registerLegacyCustomClassesForJSON(MyCustomLayer.class)

where MyCustomLayer is the custom layer.

If there are no custom layers/vertices/preprocessors, then we'll need to debug this. Either you can share your network file, or open it in a zip program and just share the configuration.json file, and I'll take a look.

@AlexDBlack AlexDBlack added the DL4J label Oct 9, 2018

@ChadiOm

This comment has been minimized.

Copy link

ChadiOm commented Oct 10, 2018

Hi Alex. Thanks for answering.

I tried NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Layer.class,GraphVertex.class,InputPreProcessor.class,IActivation.class,ILossFunction.class,ReconstructionDistribution.class); before restoring the net. I have the following error message :

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'NetPred.File2FileApp#0' defined in class path resource [spring/PredictAndDrawApplication-context.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Error deserializing ComputationGraphConfiguration - configuration may have a custom layer, vertex or preprocessor, in pre version 1.0.0-alpha JSON format. These layers can be deserialized by first registering them with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Class...)

Caused by: java.lang.RuntimeException: Error deserializing ComputationGraphConfiguration - configuration may have a custom layer, vertex or preprocessor, in pre version 1.0.0-alpha JSON format. These layers can be deserialized by first registering them with NeuralNetConfiguration.registerLegacyCustomClassesForJSON(Class...)

Caused by: org.nd4j.shade.jackson.databind.JsonMappingException: Cannot deserialize legacy JSON format of object with name "LayerVertex" of type org.deeplearning4j.nn.conf.graph.GraphVertex (through reference chain: org.deeplearning4j.nn.conf.ComputationGraphConfiguration["vertices"]->java.util.LinkedHashMap["zeropadding2d_3"])

Caused by: java.lang.IllegalStateException: Cannot deserialize legacy JSON format of object with name "LayerVertex" of type org.deeplearning4j.nn.conf.graph.GraphVertex

Caused by: org.nd4j.shade.jackson.databind.JsonMappingException: Cannot deserialize legacy JSON format of object with name "FrozenLayer" of type org.deeplearning4j.nn.conf.layers.Layer (through reference chain: org.deeplearning4j.nn.conf.graph.LayerVertex["layerConf"]->org.deeplearning4j.nn.conf.NeuralNetConfiguration["layer"])

Caused by: java.lang.IllegalStateException: Cannot deserialize legacy JSON format of object with name "FrozenLayer" of type org.deeplearning4j.nn.conf.layers.Layer

Caused by: org.nd4j.shade.jackson.databind.JsonMappingException: Conflicting setter definitions for property "listeners": org.deeplearning4j.nn.layers.wrapper.BaseWrapperLayer#setListeners(1 params) vs org.deeplearning4j.nn.layers.wrapper.BaseWrapperLayer#setListeners(1 params)

Caused by: java.lang.IllegalArgumentException: Conflicting setter definitions for property "listeners": org.deeplearning4j.nn.layers.wrapper.BaseWrapperLayer#setListeners(1 params) vs org.deeplearning4j.nn.layers.wrapper.BaseWrapperLayer#setListeners(1 params)

Please find attached my .zip containing configuration.json
network.zip

Thanx for you help.

@AlexDBlack

This comment has been minimized.

Copy link
Member

AlexDBlack commented Oct 11, 2018

Thanks for the model. I was able to reproduce this, and fix it here: #6560
The cause was a bug in the loading of frozen layers that were serialized in the old/legacy JSON format from a few versions back.

Once the pull request linked above is merged, you can access the fix using snapshots: https://deeplearning4j.org/docs/latest/deeplearning4j-config-snapshots

AlexDBlack added a commit that referenced this issue Oct 11, 2018

DL4J Fixes; remove UI and Scala name suffix from parallel wrapper mod…
…ule (#6560)

* #6552 Fix frozen layer deserialization for legacy JSON format

* Relax restrictions for Nd4j.gemm for valid vectors result arrays

* #6551 Remove logback exclusion for deeplearning4j-play

* Remove Ui dependency from parallel wrapper

* Remove scala version suffix from parallel wrapper module name

* Typo fix

* Better Nd4j.gemm validation fix
@lock

This comment has been minimized.

Copy link

lock bot commented Nov 10, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Nov 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.