Commit e0c69fe7 authored by nilsfreyer's avatar nilsfreyer

modified Network, tests, data

parent 95f0b1eb
Pipeline #109873 failed with stage
in 2 minutes and 25 seconds
......@@ -41,13 +41,13 @@ import static org.junit.Assert.assertFalse;
public class IntegrationCaffe2Test extends AbstractSymtabTest {
private Path vggTrainingHashFile = Paths.get("./target/generated-sources-emadl/cNNCalculator/VGG16.training_hash");
private Path netTrainingHashFile = Paths.get("./target/generated-sources-emadl/cNNCalculator/Network.training_hash");
private void createHashFile() {
try {
vggTrainingHashFile.toFile().getParentFile().mkdirs();
netTrainingHashFile.toFile().getParentFile().mkdirs();
List<String> lines = Arrays.asList("7A7FBAC4E0AD84993C1C5F8B4F431055#D85A46E95F839BBEE22D9AC3E6A4BC5C#6BE4AED3D0DA1940B750FEA8088A7D21#6BE4AED3D0DA1940B750FEA8088A7D21");
Files.write(vggTrainingHashFile, lines, Charset.forName("UTF-8"));
Files.write(netTrainingHashFile, lines, Charset.forName("UTF-8"));
}
catch(Exception e) {
assertFalse("Hash file could not be created", true);
......@@ -56,7 +56,7 @@ public class IntegrationCaffe2Test extends AbstractSymtabTest {
private void deleteHashFile() {
try {
Files.delete(vggTrainingHashFile);
Files.delete(netTrainingHashFile);
}
catch(Exception e) {
assertFalse("Could not delete hash file", true);
......@@ -74,13 +74,13 @@ public class IntegrationCaffe2Test extends AbstractSymtabTest {
public void testDontRetrain1() {
// The training hash is stored during the first training, so the second one is skipped
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "cNNCalculator.VGG16", "-b", "CAFFE2"};
String[] args = {"-m", "src/test/resources/models/", "-r", "cNNCalculator.Network", "-b", "CAFFE2"};
EMADLGeneratorCli.main(args);
//assertTrue(!Log.getFindings().isEmpty());
assertTrue(Log.getFindings().isEmpty());
Log.getFindings().clear();
EMADLGeneratorCli.main(args);
//assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().size() == 1);
assertTrue(Log.getFindings().get(0).getMsg().contains("skipped"));
deleteHashFile();
......@@ -92,7 +92,7 @@ public class IntegrationCaffe2Test extends AbstractSymtabTest {
Log.getFindings().clear();
createHashFile();
String[] args = {"-m", "src/test/resources/models/", "-r", "cNNCalculator.VGG16", "-b", "CAFFE2", "-f", "y"};
String[] args = {"-m", "src/test/resources/models/", "-r", "cNNCalculator.Network", "-b", "CAFFE2", "-f", "y"};
EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty());
......
package cNNCalculator;
component Add{
ports
in Z(0:999) num1,
in Z(0:999) num2,
out Z(0:1998) sum;
implementation Math{
sum = num1 + num2;
}
}
package cNNCalculator;
component ArgMax<Z(1:oo) n = 2>{
ports in Q^{n} inputVector,
out Z(0:oo) maxIndex,
out Q maxValue;
implementation Math{
maxIndex = 0;
maxValue = inputVector(1);
for i = 2:n
if inputVector(i) > maxValue
maxIndex = i - 1;
maxValue = inputVector(i);
end
end
}
}
package cNNCalculator;
component Calculator {
ports
in Q(0:1)^10 in1_1,
in Q(0:1)^10 in1_2,
in Q(0:1)^10 in1_3,
in Q(0:1)^10 in2_1,
in Q(0:1)^10 in2_2,
in Q(0:1)^10 in2_3,
out Z(0:1998) out1;
instance ArgMax<10> number1_ones;
instance ArgMax<10> number1_tens;
instance ArgMax<10> number1_hundreds;
instance ArgMax<10> number2_ones;
instance ArgMax<10> number2_tens;
instance ArgMax<10> number2_hundreds;
instance DigitCombiner number1;
instance DigitCombiner number2;
instance Add add;
connect in1_1 -> number1_hundreds.inputVector;
connect in1_2 -> number1_tens.inputVector;
connect in1_3 -> number1_ones.inputVector;
connect in2_1 -> number2_hundreds.inputVector;
connect in2_2 -> number2_tens.inputVector;
connect in2_3 -> number2_ones.inputVector;
connect number1_ones.maxIndex -> number1.ones;
connect number1_tens.maxIndex -> number1.tens;
connect number1_hundreds.maxIndex -> number1.hundreds;
connect number2_ones.maxIndex -> number2.ones;
connect number2_tens.maxIndex -> number2.tens;
connect number2_hundreds.maxIndex -> number2.hundreds;
connect number1.number -> add.num1;
connect number2.number -> add.num2;
connect add.sum -> out1;
}
package cNNCalculator;
component Connector {
ports in Z(0:255)^{1, 28, 28} image1,
in Z(0:255)^{1, 28, 28} image2,
in Z(0:255)^{1, 28, 28} image3,
in Z(0:255)^{1, 28, 28} image4,
in Z(0:255)^{1, 28, 28} image5,
in Z(0:255)^{1, 28, 28} image6,
out Z(0:1998) res;
instance Network<10> predictor1;
instance Network<10> predictor2;
instance Network<10> predictor3;
instance Network<10> predictor4;
instance Network<10> predictor5;
instance Network<10> predictor6;
instance Calculator cal;
instance ArgMax<10> maxi;
connect image1 -> predictor1.image;
connect image2 -> predictor2.image;
connect image3 -> predictor3.image;
connect image4 -> predictor4.image;
connect image5 -> predictor5.image;
connect image6 -> predictor6.image;
connect predictor1.predictions -> cal.in1_1;
connect predictor2.predictions -> cal.in1_2;
connect predictor3.predictions -> cal.in1_3;
connect predictor4.predictions -> cal.in2_1;
connect predictor5.predictions -> cal.in2_2;
connect predictor6.predictions -> cal.in2_3;
connect cal.out1 -> res;
}
package cNNCalculator;
component DigitCombiner{
ports
in Z(0:9) hundreds,
in Z(0:9) tens,
in Z(0:9) ones,
out Z(0:999) number;
implementation Math{
number = ones + 10 * tens + 100 * hundreds;
}
}
package cNNCalculator;
component Network<Z(2:oo) classes = 10>{
component Network{
ports in Z(0:255)^{1, 28, 28} image,
out Q(0:1)^{classes} predictions;
out Q(0:1)^{10} predictions;
implementation CNN {
image ->
......@@ -12,7 +12,7 @@ component Network<Z(2:oo) classes = 10>{
Pooling(pool_type="max", kernel=(2,2), stride=(2,2), padding="valid") ->
FullyConnected(units=500) ->
Relu() ->
FullyConnected(units=classes) ->
FullyConnected(units=10) ->
Softmax() ->
predictions
......
configuration VGG16{
num_epoch:1
batch_size:64
normalize:true
load_checkpoint:false
optimizer:adam{
learning_rate:0.01
learning_rate_decay:0.8
step_size:1000
weight_decay: 0.01
}
}
package cNNCalculator;
component VGG16{
ports in Z(0:255)^{1, 28, 28} image,
out Q(0:1)^{10} predictions;
implementation CNN {
def conv(filter, channels){
Convolution(kernel=(filter,filter), channels=channels) ->
Relu()
}
def fc(){
FullyConnected(units=100) ->
Relu() ->
Dropout(p=0.5)
}
image ->
conv(filter=2, channels=64, ->=2) ->
Pooling(pool_type="max", kernel=(2,2), stride=(1,1)) ->
fc() ->
FullyConnected(units=10) ->
Softmax() ->
predictions
}
}
cifar10.CifarNetwork src/test/resources/training_data
cNNCalculator.VGG16 src/test/resources/training_data
cNNCalculator.Network src/test/resources/training_data
MultipleOutputs data/MultipleOutputs
InstanceTest.NetworkB data/InstanceTest.NetworkB
Alexnet data/Alexnet
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment