Skip to content
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

IndexOutOfBoundsException while importing a model from configuration file #247

Open
axyonovleonid opened this issue Sep 27, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@axyonovleonid
Copy link

axyonovleonid commented Sep 27, 2021

Hi,

Kotlin DL v. 0.0.2
color_model.txt

I'm trying to adapt this (see 'Build & Compile the Model') section network as it shown at importing existing nn guide. I've exported model config in json format (config gist or color_model.txt in attachments) and when I try call
Sequential.loadModelConfiguration(config) I get an exeption

Caused by: java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 2 at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) at java.base/java.util.Objects.checkIndex(Objects.java:373) at java.base/java.util.ArrayList.get(ArrayList.java:425) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.loadSequentialModelLayers(ModelLoader.kt:115) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.loadModelConfiguration(ModelLoader.kt:44) at org.jetbrains.kotlinx.dl.api.core.Sequential$Companion.loadModelConfiguration(Sequential.kt:66) at com.my.nets.ColorClassifier.<init>(ColorClassifier.kt:17) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

I've figured out that exception occurs at "batch_input_shape" array independently from it's size and content. Am I doing smth wrong or there really is a problem with reading?

@zaleslaw
Copy link
Collaborator

Could you please try the same thing with the new version 0.3.0, which will be released today? Probably this problem will be fixed?
Thanks for providing so much helpful feedback on this issue. I'll try to reproduce and return in 2-3 days.

Meanwhile, you could try a new version and share results here in the issue.

@zaleslaw zaleslaw added the bug Something isn't working label Sep 28, 2021
@axyonovleonid
Copy link
Author

axyonovleonid commented Sep 28, 2021

Yeah, it's gone in the new version. But another problems occured. Now I get NLP at model configuration stage

Caused by: java.lang.NullPointerException: null at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.convertToRegularizer(ModelLoader.kt:225) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.createDenseLayer(ModelLoader.kt:557) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.convertToLayer(ModelLoader.kt:77) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.loadSequentialModelLayers(ModelLoader.kt:65) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.deserializeSequentialModel(ModelLoader.kt:45) at org.jetbrains.kotlinx.dl.api.inference.keras.ModelLoaderKt.loadSequentialModelConfiguration(ModelLoader.kt:41) at org.jetbrains.kotlinx.dl.api.core.Sequential$Companion.loadModelConfiguration(Sequential.kt:69) at com.my.nets.ColorClassifier.<init>(ColorClassifier.kt:17) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481) at kotlin.reflect.jvm.internal.calls.CallerImpl$Constructor.call(CallerImpl.kt:41) at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108) at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159) at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112) at org.springframework.beans.BeanUtils$KotlinDelegate.instantiateClass(BeanUtils.java:798) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:189) ... 22 common frames omitted

I tried to change NN config in Jupyter and specify all of parameters I see in model.json and replace other null fields in config with zeros or smth valueable, but it didn't help. Actually I'm quite new to NN projecting, so I'm not sure it should have helped

Models
model_as_is_from_jupyter.txt

model_with_null_avoidance.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants