use of org.deeplearning4j.exception.DL4JException in project deeplearning4j by deeplearning4j.
the class TestInvalidConfigurations method testDenseNout0.
@Test
public void testDenseNout0() {
try {
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list().layer(0, new DenseLayer.Builder().nIn(10).nOut(0).build()).layer(1, new OutputLayer.Builder().nIn(10).nOut(10).build()).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testDenseNout0(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.deeplearning4j.exception.DL4JException in project deeplearning4j by deeplearning4j.
the class TestInvalidConfigurations method testCnnInvalidConfigOrInput_SmallerDataThanKernel.
@Test
public void testCnnInvalidConfigOrInput_SmallerDataThanKernel() {
//Idea: same as testCnnInvalidConfigPaddingStridesHeight() but network is fed incorrect sized data
// or equivalently, network is set up without using InputType functionality (hence missing validation there)
int depthIn = 3;
int hIn = 10;
int wIn = 10;
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list().layer(0, new ConvolutionLayer.Builder().kernelSize(7, 7).stride(1, 1).padding(0, 0).nOut(5).build()).layer(1, new OutputLayer.Builder().nOut(10).build()).setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
try {
net.feedForward(Nd4j.create(3, depthIn, 5, 5));
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testCnnInvalidConfigOrInput_SmallerDataThanKernel(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.deeplearning4j.exception.DL4JException in project deeplearning4j by deeplearning4j.
the class TestInvalidConfigurations method testCnnInvalidConfigOrInput_BadStrides.
@Test
public void testCnnInvalidConfigOrInput_BadStrides() {
//Idea: same as testCnnInvalidConfigPaddingStridesHeight() but network is fed incorrect sized data
// or equivalently, network is set up without using InputType functionality (hence missing validation there)
int depthIn = 3;
int hIn = 10;
int wIn = 10;
//Invalid: (10-3+0)/2+1 = 4.5
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict).list().layer(0, new ConvolutionLayer.Builder().kernelSize(3, 3).stride(2, 2).padding(0, 0).nIn(depthIn).nOut(5).build()).layer(1, new OutputLayer.Builder().nIn(5 * 4 * 4).nOut(10).build()).inputPreProcessor(1, new CnnToFeedForwardPreProcessor()).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
try {
net.feedForward(Nd4j.create(3, depthIn, hIn, wIn));
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testCnnInvalidConfigOrInput_BadStrides(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.deeplearning4j.exception.DL4JException in project deeplearning4j by deeplearning4j.
the class TestInvalidConfigurations method testCnnInvalidConfigPaddingStridesHeight.
@Test
public void testCnnInvalidConfigPaddingStridesHeight() {
//Idea: some combination of padding/strides are invalid.
int depthIn = 3;
int hIn = 10;
int wIn = 10;
try {
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().convolutionMode(ConvolutionMode.Strict).list().layer(0, new ConvolutionLayer.Builder().kernelSize(3, 2).stride(2, 2).padding(0, 0).nOut(5).build()).layer(1, new OutputLayer.Builder().nOut(10).build()).setInputType(InputType.convolutional(hIn, wIn, depthIn)).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testCnnInvalidConfigPaddingStridesHeight(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of org.deeplearning4j.exception.DL4JException in project deeplearning4j by deeplearning4j.
the class TestInvalidConfigurations method testLSTMNOut0.
@Test
public void testLSTMNOut0() {
try {
MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder().list().layer(0, new GravesLSTM.Builder().nIn(10).nOut(0).build()).layer(1, new RnnOutputLayer.Builder().nIn(10).nOut(10).build()).build();
MultiLayerNetwork net = new MultiLayerNetwork(conf);
net.init();
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testLSTMNOut0(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
Aggregations