How to get the input shape required by a model loaded with KerasModelImport

I am loading a pretrained model from keras, using KerasModelImport.
I would like to know the dimensions of the input required for the model.
When I feed the network an input with the wrong dimensions the resulting error has the dimensions required, how do I get this dimensions from the Loading of the model?

@SSdev keras directly tells you what the input is. If you need to view the architecture, you can use netron for that: GitHub - lutzroeder/netron: Visualizer for neural network, deep learning and machine learning models

Thanks for your reply @agibsonccc, but what I want is the size of the input required when I load the keras model in DL4j. I want to get the input dimensions required in java after loading the model.

For instance, if I kerasImport many models in DL4j, how can I automatically resize the inputs for prediction, for this I would need the size of the inputs the actual keras model was trained on.

So i was thinking, is there a method that can give me the dimensions on the input after loading the ComputationalGraph.
maybe:
modelK = KerasModelImport.importKerasModelAndWeights(path, False);
int dim = modelK.getInputDimension();

where dim = N,C,H,W

@SSdev sorry just checking on this again, the size should be the exact same as python. There’s nothing you should need to do for java. For the input data pipeline, you would just use our NativeImageLoader to resize it to the height/width you’d want.

thank you for your response @agibsonccc
I was hoping I can extract the dimensions of the imported model input required in DL4J in java.
That’s ok, alternatively i created a parameter file that my java code can access with the dimensions. So my problem was solved that way.

Just checking in to see if there is a better solution to this? I am having the same problem, and don’t like the idea of having to have a parameter file along with my model file. Surely in the model there is some way of extracting the dimensions of the expected input.

@bugzyUK the input shape should come from keras. If your input is unspecified it might have issues. Please open a new post with your specific example and I’ll see if I can help.