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

network.init(netParams, false) throws an exception in 1.0.0-beta4 #7889

Closed
cqiaoYc opened this issue Jun 8, 2019 · 4 comments
Closed

network.init(netParams, false) throws an exception in 1.0.0-beta4 #7889

cqiaoYc opened this issue Jun 8, 2019 · 4 comments
Labels
DL4J General DeepLearning4j issues

Comments

@cqiaoYc
Copy link

cqiaoYc commented Jun 8, 2019

Issue Description

network.init(netParams, false) throws an exception in 1.0.0-beta4. It's fine in 1.0.0-beta3.

MultiLayerNetwork network = new MultiLayerNetwork(multiLayerNetConfig.clone());
network.init(netParams, false);

Exception in thread "pool-1-thread-1" Exception in thread "pool-1-thread-2" java.lang.IllegalStateException: Illegal set of indices for array: need at least 1 point/interval/all/specified indices for rank 1 array ([114]), got indices [Interval(b=0,e=0,s=1,inclusive), Interval(b=0,e=60,s=1)]
at org.nd4j.base.Preconditions.throwStateEx(Preconditions.java:641)
at org.nd4j.base.Preconditions.checkState(Preconditions.java:412)
at org.nd4j.linalg.api.ndarray.BaseNDArray.get(BaseNDArray.java:4910)
at org.deeplearning4j.nn.multilayer.MultiLayerNetwork.init(MultiLayerNetwork.java:699)

Version Information

  • Deeplearning4j version: 1.0.0-beta4
  • platform information (OS, etc): windows 10, ubuntu 18.04
  • CUDA version, 10
  • NVIDIA driver version: 7.4
@AlexDBlack
Copy link
Contributor

My guess here is you are passing in a 1D array for netParams.
As always, I need code to reproduce this before I can look into it.

@AlexDBlack AlexDBlack added the DL4J General DeepLearning4j issues label Jun 8, 2019
@cqiaoYc
Copy link
Author

cqiaoYc commented Jun 8, 2019

Yes , the netParams is a 1D array. I train net using GA, the code likes:

MultiLayerConfiguration netConfig = getMultiLayerNetConfig(featureCount);
MultiLayerNetwork net = new MultiLayerNetwork(netConfig.clone());
net.init();
nt netParamsCount = (int)net.numParams();
for(int i=0;i<10;++i){
     INDArray netParams=Nd4j.randn(netParamsCount);
     MultiLayerNetwork network = new MultiLayerNetwork(multiLayerNetConfig.clone());
     network.init(netParams, false);
       ....
}

@cqiaoYc
Copy link
Author

cqiaoYc commented Jun 8, 2019

It is fine:

 INDArray netParams=Nd4j.randn(netParamsCount);
netParams=netParams.reshape(new int[]{1,(int)netParams.shape()[0]});

@AlexDBlack
Copy link
Contributor

Thanks. We'll add some more validation and a useful exception so it's more obvious what the problem is... #7890

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DL4J General DeepLearning4j issues
Projects
None yet
Development

No branches or pull requests

2 participants