deeplearning4j/deeplearning4j

Op [multiply] execution failed

Closed this issue · 1 comments

Issue Description

I am just a beginner. This is a neural network that I have simply configured based on myself. The network initialization is not a problem, but there was an error when feeding data. I am very confused and don't know why. Here is my code.

`
public class LSTMTest {

public static void main(String[] args) {

    ComputationGraphConfiguration conf = new NeuralNetConfiguration.Builder()
            .graphBuilder()
            .addInputs("input") 
            .setInputTypes(InputType.recurrent(5))
            .addLayer("L1", new LSTM.Builder().activation(Activation.TANH).nIn(5).nOut(10).build(), "input")
            .addLayer("L2",new DenseLayer.Builder().nIn(10).nOut(4).activation(Activation.RELU).build(),"L1")
            .addLayer("L3",new OutputLayer.Builder().nIn(4).nOut(2).activation(Activation.SOFTMAX).build(),"L2")
            .inputPreProcessor("L2",new RnnToFeedForwardPreProcessor())
            .setOutputs("L3")	
            .build();

    ComputationGraph net = new ComputationGraph(conf);
    net.init();

    INDArray labelsData = Nd4j.rand(16,2);
    INDArray featuresData = Nd4j.rand(2,5,8);

    net.fit(new INDArray[]{featuresData},new INDArray[]{labelsData});



}

}
`

Version Information

  • 1.0.0-M2.1
  • windows 10

Additional information

Error message:

MULTIPLY OP: the shapes of x [16, 10] and y [2, 10] are not suitable for broadcast ! o.n.l.c.n.o.NativeOpExecutioner - Failed to execute op multiply. Attempted to execute with 2 inputs, 1 outputs, 0 targs,0 bargs and 0 iargs. Inputs: [(FLOAT,[16,10],f), (FLOAT,[2,10],f)]. Outputs: [(FLOAT,[16,10],f)]. tArgs: -. iArgs: -. bArgs: -. Op own name: "0459df1b-0c9c-49f3-85f0-356f27ae11c2" - Please see above message (printed out from c++) for a possible cause of error. Exception in thread "main" java.lang.RuntimeException: Op [multiply] execution failed at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.exec(NativeOpExecutioner.java:1561) at org.deeplearning4j.nn.layers.recurrent.LSTMHelpers.backpropGradientHelper(LSTMHelpers.java:575) at org.deeplearning4j.nn.layers.recurrent.LSTM.backpropGradientHelper(LSTM.java:95) at org.deeplearning4j.nn.layers.recurrent.LSTM.backpropGradient(LSTM.java:67) at org.deeplearning4j.nn.graph.vertex.impl.LayerVertex.doBackward(LayerVertex.java:148) at org.deeplearning4j.nn.graph.ComputationGraph.calcBackpropGradients(ComputationGraph.java:2784) at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore(ComputationGraph.java:1393) at org.deeplearning4j.nn.graph.ComputationGraph.computeGradientAndScore(ComputationGraph.java:1353) at org.deeplearning4j.optimize.solvers.BaseOptimizer.gradientAndScore(BaseOptimizer.java:174) at org.deeplearning4j.optimize.solvers.StochasticGradientDescent.optimize(StochasticGradientDescent.java:61) at org.deeplearning4j.optimize.Solver.optimize(Solver.java:52) at org.deeplearning4j.nn.graph.ComputationGraph.fitHelper(ComputationGraph.java:1177) at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:1127) at org.deeplearning4j.nn.graph.ComputationGraph.fit(ComputationGraph.java:1114) at org.deeplearning4j.examples.wip.quickstart.modelling.LSTMTest.main(LSTMTest.java:40) Caused by: java.lang.RuntimeException: Op with name 0459df1b-0c9c-49f3-85f0-356f27ae11c2 and op type [multiply] execution failed with message Op validation failed at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.exec(NativeOpExecutioner.java:1905) at org.nd4j.linalg.cpu.nativecpu.ops.NativeOpExecutioner.exec(NativeOpExecutioner.java:1540) ... 14 more

Closing this. This is not a bug. The error tells you what your issue is. It's expecting 2 arrays of the same shape. Please at my name on the community forums: https://community.konduit.ai/ for further help.