deeplearning4j / deeplearning4j-examples

Deeplearning4j Examples (DL4J, DL4J Spark, DataVec)
http://deeplearning4j.konduit.ai
Other
2.46k stars 1.82k forks source link

NeuralStyleTransfer failed #659

Closed sjsdfg closed 6 years ago

sjsdfg commented 6 years ago

when i run this example NeuralStyleTransfer i get an NPE.

1:24:31,059 INFO  ~ iteration  0
Exception in thread "main" java.lang.NullPointerException
    at org.deeplearning4j.nn.layers.convolution.ConvolutionLayer.backpropGradient(ConvolutionLayer.java:134)
    at org.deeplearning4j.examples.styletransfer.NeuralStyleTransfer.backPropagate(NeuralStyleTransfer.java:284)
    at org.deeplearning4j.examples.styletransfer.NeuralStyleTransfer.backPropagateStyles(NeuralStyleTransfer.java:159)
    at org.deeplearning4j.examples.styletransfer.NeuralStyleTransfer.transferStyle(NeuralStyleTransfer.java:131)
    at org.deeplearning4j.examples.styletransfer.NeuralStyleTransfer.main(NeuralStyleTransfer.java:108)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

the exception is caused by 134 line in ConvolutionLayer.java:134 the content is int miniBatch = this.input.size(0);

what causes this? that value should be 1.

RobAltena commented 6 years ago

I have reproduced this error on 1.0.0-alpha.

liweigu commented 6 years ago

int miniBatch = input.size(0); The 'input' is null there.

liweigu commented 6 years ago

I found a way to run this example: 1) Comment out the line: Map<String, INDArray> activationsCombMap = vgg16FineTune.feedForward(combination, true); 2) Add these codes instead: INDArray[] input = new INDArray[] { combination }; boolean train = true; boolean clearInputs = false; Map<String, INDArray> activationsCombMap = vgg16FineTune.feedForward(input, train, clearInputs);

RobAltena commented 6 years ago

@liweigu Thank you for fixing the issue. Appreciated.

sjsdfg commented 6 years ago

that is magic. when i debug this program. after line 131, the inputs is still in vgg16FineTune. how can i insert a picture to show that?

sjsdfg commented 6 years ago

http://static.zybuluo.com/ZzzJoe/jaej72978fpr7sunqrky9zon/QQ%E5%9B%BE%E7%89%8720180410091824.png the debug picture