I tried to load a keras 2 - inception v3 weights file with dl4j model import 1.0.0-beta version, but receiving this error, while trying to revive the computational graph.
org.deeplearning4j.exception.DL4JInvalidConfigException: Invalid configuration for layer (idx=-1, name=conv2d_5, type=ConvolutionLayer) for height dimension: Invalid input configuration for kernel height. Require 0 < kH <= inHeight + 2*padH; got (kH=3, inHeight=0, padH=0)
Input type = InputTypeConvolutional(h=0,w=0,c=3), kernel = [3, 3], strides = [2, 2], padding = [0, 0], layer size (output channels) = 32, convolution mode = Truncate
I checked with dl4j model import modules test and saw that you have ignored that test for some reason:
https://github.com/deeplearning4j/deeplearning4j/blob/master/deeplearning4j/deeplearning4j-modelimport/src/test/java/org/deeplearning4j/nn/modelimport/keras/e2e/KerasModelEndToEndTest.java#L410-L419
I also verified that, the keras model that has been used here "inception_v3_complete.h5" is a keras-1 model but you have a keras-2 weights file in test resources: https://github.com/deeplearning4j/dl4j-test-resources/tree/master/src/main/resources/modelimport/keras/examples/inception
Why aren't there any tests for the keras-2 model?
If I need to get this working, how should I proceed?
Thank you!
Thanks for reporting this, I'll get around to this quickly and let you know how you can help (if at all).
To answer your questions: yes, we can always improve test by coverage and this should be added. Not sure how the two files got there, probably by mistake.
have a look at the PR, it shows how to provide input shape for that model, so that shape info can be propagated through the model and you don't get your "0 height and width" errors as above. thanks again
馃憤 so the tests are added, great. Which PR are you referencing @maxpumperla ?
or wait, I think you are referencing https://github.com/deeplearning4j/deeplearning4j/commit/a0a0234d611311a2a736c38adb784af4f6f2b5aa right? FYI @ThejanW
@maxpumperla thanks a bunch for the prompt reply :100: @chrismattmann thank you for looking into this.
I tried it this way too, dunno how this test is working, because I tried the exact same thing. First I tried something like this,
graph = KerasModelImport.importKerasModelAndWeights("/home/thejan/Desktop/inception_tf_keras_2.h5", false);
which gave me the error of:
org.deeplearning4j.exception.DL4JInvalidConfigException: Invalid configuration for layer (idx=-1, name=conv2d_5, type=ConvolutionLayer) for height dimension: Invalid input configuration for kernel height. Require 0 < kH <= inHeight + 2*padH; got (kH=3, inHeight=0, padH=0)
Input type = InputTypeConvolutional(h=0,w=0,c=3), kernel = [3, 3], strides = [2, 2], padding = [0, 0], layer size (output channels) = 32, convolution mode = Truncate
that means importKerasModelAndWeights is no longer working the way it is supposed to work, so there's a bug there.
I also tried to get the comp graph this way(as in the other tests; verified this method is working because you added inception test the exact same way.),
KerasModelBuilder builder = new KerasModel().modelBuilder().modelHdf5Filename("/home/thejan/Desktop/inception_tf_keras_2.h5").enforceTrainingConfig(false);
builder.inputShape(new int[]{299, 299, 3});
KerasModel model = builder.buildModel();
ComputationGraph graph = model.getComputationGraph();
this gives me java.lang.NullPointerException at builder.buildModel(),
Is there anything wrong with my approach?
@ThejanW don't jump to conclusions too quickly. If the unit test passes for me it means it passes on master. It also works on snapshots. It does fail on 1.0.0-beta, So "there's a bug there" is a statement of the past. Use snapshots!
If you use the builder pattern or not to use import doesn't matter (internally it's using it anyway).
In case you still have problems, consider opening another issue.
thanks a ton @maxpumperla :100: :100: builder API worked like a charm with the SNAPSHOT, the error is in the latest released version in Maven : 1.0.0-beta, not with the current master or snapshots, I understand. But still getting this shape propagation issue when using KerasModelImport.importKerasModelAndWeights(), I saved a inception model in Keras after replacing all its dynamic shapes into static shapes and used that with KerasModelImport.importKerasModelAndWeights() and it worked fine, so KerasModelImport.importKerasModelAndWeights() perhaps has an issue with dynamic shapes, yet. I will raise a separate issue for that.
Sorry, didn't mean to judge this amazing model import feature you guys are working on. Keep up the good work.
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.