Unverified Commit 18547df4 authored by Thomas Michael Timmermanns's avatar Thomas Michael Timmermanns Committed by GitHub

Changed Range syntax and added ResNet152 architecture. (#24)

* Changed Range syntax and added ResNet152 architecture.

* Add files via upload

* Add files via upload

* Update README.md

* Update README.md

* Update README.md
parent 456a2570
......@@ -128,21 +128,17 @@ The body of a new method is constructed from other layers including other user-d
The compiler will throw an error if recursion occurs.
The following is a example of multiple method declarations.
```
def conv(filter, channels, stride=1, act=true){
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
def skip(channels, stride){
Convolution(kernel=(1,1), channels=channels, stride=(stride,stride)) ->
BatchNorm()
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
conv(kernel=1, channels=channels, stride=stride, act=false, ?=(stride!=1))
) ->
Add() ->
Relu()
......@@ -151,30 +147,18 @@ The following is a example of multiple method declarations.
The method `resLayer` in this example corresponds to a building block of a Residual Network.
The `?` argument is a special argument which is explained in the next section.
## Special Arguments
There exists special structural arguments which can be used in each method.
These are `->`, `|` and `?`. `->` and `|` can only be positive integers and `?` can only be a boolean.
The argument `?` does nothing if it is true and removes the layer completely if it is false.
The other two arguments create an iteration of the method.
We will show their effect with examples.
## Structural Arguments
Structural arguments are special arguments which can be set for each layer and which do not correspond to a layer parameter. The three structural arguments are "?", "->" and "|". The conditional argument "?" is a boolean. It does nothing if it is true and it removes the layer completely if it is false. This argument is only useful for layer construction. The other two structural arguments are non-negative integers which repeat the layer *x* number of times where *x* is equal to their value. The layer operator between each repetition has the same symbol as the argument.
Assuming `a` is a method without required arguments,
then `a(-> = 3)->` is equal to `a()->a()->a()->`,
`a(| = 3)->` is equal to `(a() | a() | a())->` and
`a(-> = 3, | = 2)->` is equal to `(a()->a()->a() | a()->a()->a())->`.
## Argument Sequences
It is also possible to iterate a method through the use of argument sequences.
The following are valid sequences: `[2->5->3]`, `[true|false|false]`, `[2->1|4->4->6]`, `[ |2->3]`, `1->..->5` and `3|..|-2`.
All values in these examples could also be replaced by variable names or expressions.
The first three are standard sequences and the last two are ranges.
A range can be translated to a standard sequence.
The range `3|..|-2` is equal to `[3|2|1|0|-1|-2]` and `1->..->5` is equal to `[1->2->3->4->5]`.
If a argument is set to a sequence, the method will be repeated for each value in the sequence and the connection between the layers will be the same as it is between the values of the sequence.
An argument which has a single value is neutral to the repetition which means that it will be repeated an arbitrary number of times without interfering with the repetition.
If a method contains multiple argument sequences, CNNArch will try to combine the sequences.
The language will throw an error at compile time if this fails.
Assuming the method `m(a, b, c)` exists, the line `m(a=[5->3], b=[3|4|2], c=2)->` is equal to:
Argument sequences can be used instead of regular arguments to declare that a layer should be repeated with the values of the given sequence. The operator between these so stacked layers is also given by the sequence. Other arguments that only have a single value are neutral to the repetition which means that the single value will be repeated an arbitrary number of times without having influence on the number of repetitions.
The following are valid sequences: `[1->2->3->4]`, `[true | false]`, `{[1 | 3->2]`, `[ |2->3]` and `[1->..->4]`. All values in these examples could also be replaced by variable names or arithmetic or logical expressions. The last sequence is defined as a range and equal to the first one. A range in CNNArch is closed which means the start and end value are both in the sequence. Moreover, a range has always a step size of one. Thus, the range `[0|..|-4]` would be empty. The data flow operators can be used both in the same argument sequence in which case a single parallelization block is created. A parallel group in this block can be empty, which is why `[ |2->3]` is a valid sequence. If a method contains multiple argument sequences, the language will try to combine them by expanding the smaller one and will throw an error at model creation if this fails. Let `m` be a layer with parameters `a`, `b` and `c`, then the expression `m(a=[3->2],b=1)` is equal to `m(a=3,b=1)->m(a=2,b=1)`. Furthermore, the line `m(a=[5->3],b=[3|4|2],c=2)->` is equal to:
```
(
m(a=5, b=3, c=2) ->
......@@ -187,7 +171,7 @@ Assuming the method `m(a, b, c)` exists, the line `m(a=[5->3], b=[3|4|2], c=2)->
m(a=3, b=2, c=2)
) ->
```
And `m(a=[|5|3->4], b=[1|1|2], c=2)` is equal to:
And `m(a=[|5|3->4], b=[|1|2], c=2)` is equal to:
```
(
......@@ -198,7 +182,7 @@ And `m(a=[|5|3->4], b=[1|1|2], c=2)` is equal to:
m(a=4, b=2, c=2)
) ->
```
However, `m(a=[5->3], b=[2|4->6], c=2)->` and `m(a=[5->3], b=[2->4->6], c=2)->` would throw an error because it is not possible to expand *a* such that it is the same size as *b*.
However, `m(a=[5->3], b=[2|4->6], c=2)->` and `m(a=[5->3], b=[2->4->6], c=2)->` would fail because it is not possible to expand *a* such that it is the same size as *b*.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -64,11 +64,11 @@ grammar CNNArch extends de.monticore.lang.math.Math {
ArchSerialSequence = serialValues:(ArchSimpleExpression || "->")*;
ArchValueRange implements ArchValueSequence = start:ArchSimpleExpression
ArchValueRange implements ArchValueSequence = "[" start:ArchSimpleExpression
(serial:"->" | parallel:"|")
".."
(serial2:"->" | parallel2:"|")
end:ArchSimpleExpression;
end:ArchSimpleExpression "]";
ArchSimpleExpression = (arithmeticExpression:MathArithmeticExpression
......
......@@ -145,22 +145,7 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
return computeValue((MathNameExpressionSymbol) getMathExpression().get());
}
else if (getMathExpression().get() instanceof TupleExpressionSymbol){
Map<String, String> replacementMap = new HashMap<>();
List<Object> valueList = new ArrayList<>();
TupleExpressionSymbol tuple = (TupleExpressionSymbol) getMathExpression().get();
for (MathExpressionSymbol mathExp : tuple.getExpressions()){
if (mathExp instanceof MathNameExpressionSymbol){
valueList.add(computeValue((MathNameExpressionSymbol) mathExp));
}
else {
ArchSimpleExpressionSymbol temp = ArchSimpleExpressionSymbol.of(mathExp);
temp.setEnclosingScope(getEnclosingScope().getAsMutableScope());
temp.resolveOrError();
valueList.add(temp.getValue().get());
getEnclosingScope().getAsMutableScope().remove(temp);
}
}
return valueList;
return computeValue((TupleExpressionSymbol) getMathExpression().get());
}
else {
Map<String, String> replacementMap = new HashMap<>();
......@@ -179,8 +164,25 @@ public class ArchSimpleExpressionSymbol extends ArchExpressionSymbol {
}
}
private List<Object> computeValue(TupleExpressionSymbol tupleExpression){
List<Object> valueList = new ArrayList<>();
for (MathExpressionSymbol mathExp : tupleExpression.getExpressions()){
if (mathExp instanceof MathNameExpressionSymbol){
valueList.add(computeValue((MathNameExpressionSymbol) mathExp));
}
else {
ArchSimpleExpressionSymbol temp = ArchSimpleExpressionSymbol.of(mathExp);
temp.setEnclosingScope(getEnclosingScope().getAsMutableScope());
temp.resolveOrError();
valueList.add(temp.getValue().get());
getEnclosingScope().getAsMutableScope().remove(temp);
}
}
return valueList;
}
private Object computeValue(MathNameExpressionSymbol mathExpression){
String name = ((MathNameExpressionSymbol) mathExpression).getNameToAccess();
String name = mathExpression.getNameToAccess();
VariableSymbol variable = (VariableSymbol) getEnclosingScope().resolve(name, VariableSymbol.KIND).get();
variable.getExpression().resolveOrError();
......
......@@ -27,9 +27,11 @@ import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSym
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchLanguage;
import de.monticore.symboltable.GlobalScope;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
import java.nio.file.Paths;
import static de.monticore.lang.monticar.cnnarch.ParserTest.ENABLE_FAIL_QUICK;
import static org.junit.Assert.assertNotNull;
public class AbstractSymtabTest {
......
......@@ -23,14 +23,24 @@ package de.monticore.lang.monticar.cnnarch;
import de.monticore.lang.monticar.cnnarch._parser.CNNArchParser;
import de.monticore.lang.monticar.cnnarch._symboltable.CNNArchCompilationUnitSymbol;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static de.monticore.lang.monticar.cnnarch.ParserTest.ENABLE_FAIL_QUICK;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class SymtabTest extends AbstractSymtabTest {
@Before
public void setUp() {
// ensure an empty log
Log.getFindings().clear();
Log.enableFailQuick(ENABLE_FAIL_QUICK);
}
@Test
public void testParsing() throws Exception {
CNNArchParser parser = new CNNArchParser();
......
......@@ -23,10 +23,13 @@ package de.monticore.lang.monticar.cnnarch.cocos;
import de.monticore.lang.monticar.cnnarch._cocos.*;
import de.monticore.lang.monticar.cnnarch.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static de.monticore.lang.monticar.cnnarch.ParserTest.ENABLE_FAIL_QUICK;
public class AllCoCoTest extends AbstractCoCoTest {
String baseDir="src/test/resources";
......@@ -34,9 +37,17 @@ public class AllCoCoTest extends AbstractCoCoTest {
Log.enableFailQuick(false);
}
@Before
public void setUp() {
// ensure an empty log
Log.getFindings().clear();
Log.enableFailQuick(ENABLE_FAIL_QUICK);
}
@Test
public void testValidCoCos() throws IOException {
checkValid("architectures", "ResNet152");
checkValid("architectures", "Alexnet");
checkValid("architectures", "ResNeXt50");
checkValid("architectures", "ResNet34");
......
architecture Alexnet(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def split1(i){
[i] ->
......@@ -39,5 +39,5 @@ architecture Alexnet(img_height=224, img_width=224, img_channels=3, classes=10){
fc(->=2) ->
FullyConnected(units=10) ->
Softmax() ->
softmax
predictions
}
\ No newline at end of file
architecture ResNeXt50(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=filter, channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=kernel, channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
def resGroup(innerChannels, outChannels, stride=1){
conv(filter=(1,1), channels=innerChannels) ->
conv(filter=(3,3), channels=innerChannels, stride=stride) ->
conv(filter=(1,1), channels=outChannels, act=false)
conv(kernel=(1,1), channels=innerChannels) ->
conv(kernel=(3,3), channels=innerChannels, stride=stride) ->
conv(kernel=(1,1), channels=outChannels, act=false)
}
def skip(outChannels, stride){
Convolution(kernel=(1,1), channels=outChannels, stride=(stride,stride)) ->
BatchNorm()
}
def resLayer(innerChannels, outChannels, stride=1, changedChannels=false){
def resLayer(innerChannels, outChannels, stride=1, addSkipConv=false){
(
resGroup(innerChannels=innerChannels,
outChannels=outChannels,
......@@ -24,24 +24,25 @@ architecture ResNeXt50(img_height=224, img_width=224, img_channels=3, classes=10
| = 32) ->
Add()
|
skip(outChannels=outChannels, stride=stride, ? = stride!=1 || changedChannels)
skip(outChannels=outChannels, stride=stride, ? = addSkipConv)
) ->
Add() ->
Relu()
}
data ->
conv(filter=(7,7), channels=64, stride=2) ->
conv(kernel=(7,7), channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2)) ->
resLayer(innerChannels=4, outChannels=256, changedChannels=true, -> = 3) ->
resLayer(innerChannels=8, outChannels=512, stride=2) ->
resLayer(innerChannels=4, outChannels=256, addSkipConv=true) ->
resLayer(innerChannels=4, outChannels=256, -> = 2) ->
resLayer(innerChannels=8, outChannels=512, stride=2, addSkipConv=true) ->
resLayer(innerChannels=8, outChannels=512, -> = 3) ->
resLayer(innerChannels=16, outChannels=1024, stride=2) ->
resLayer(innerChannels=16, outChannels=1024, stride=2, addSkipConv=true) ->
resLayer(innerChannels=16, outChannels=1024, -> = 5) ->
resLayer(innerChannels=32, outChannels=2048, stride=2) ->
resLayer(innerChannels=32, outChannels=2048, stride=2, addSkipConv=true) ->
resLayer(innerChannels=32, outChannels=2048, -> = 2) ->
GlobalPooling(pool_type="avg") ->
FullyConnected(units=classes) ->
Softmax() ->
softmax
predictions
}
\ No newline at end of file
architecture ResNet152(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} predictions
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
def skip(channels, stride){
Convolution(kernel=(1,1), channels=channels, stride=(stride,stride)) ->
BatchNorm()
}
def resLayer(channels, stride=1, addSkipConv=false){
(
conv(kernel=1, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels) ->
conv(kernel=1, channels=4*channels, act=false)
|
skip(channels=4*channels, stride=stride, ? = addSkipConv)
) ->
Add() ->
Relu()
}
data ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2)) ->
resLayer(channels=64, addSkipConv=true) ->
resLayer(channels=64, ->=2) ->
resLayer(channels=128, stride=2, addSkipConv=true) ->
resLayer(channels=128, ->=7) ->
resLayer(channels=256, stride=2, addSkipConv=true) ->
resLayer(channels=256, ->=35) ->
resLayer(channels=512, stride=2, addSkipConv=true) ->
resLayer(channels=512, ->=2) ->
GlobalPooling(pool_type="avg") ->
FullyConnected(units=classes) ->
Softmax() ->
predictions
}
\ No newline at end of file
architecture ResNet34(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ResNet34(img_height=224, img_width=224, img_channels=3, classes=100
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, act=false)
|
skip(channels=channels, stride=stride, ? = (stride != 1))
) ->
......@@ -23,7 +23,7 @@ architecture ResNet34(img_height=224, img_width=224, img_channels=3, classes=100
}
data ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2)) ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......@@ -35,5 +35,5 @@ architecture ResNet34(img_height=224, img_width=224, img_channels=3, classes=100
GlobalPooling(pool_type="avg") ->
FullyConnected(units=classes) ->
Softmax() ->
softmax
predictions
}
architecture SequentialAlexnet(img_height=224, img_width=224, img_channels=3, classes=10){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def conv(filter, channels, hasPool=true, convStride=(1,1)){
Convolution(kernel=filter, channels=channels, stride=convStride) ->
def conv(kernel, channels, hasPool=true, convStride=(1,1)){
Convolution(kernel=kernel, channels=channels, stride=convStride) ->
Relu() ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), ?=hasPool)
}
......@@ -14,16 +14,16 @@ architecture SequentialAlexnet(img_height=224, img_width=224, img_channels=3, cl
}
data ->
conv(filter=(11,11), channels=96, convStride=(4,4)) ->
conv(kernel=(11,11), channels=96, convStride=(4,4)) ->
Lrn(nsize=5, alpha=0.0001, beta=0.75) ->
conv(filter=(5,5), channels=256, convStride=(4,4)) ->
conv(kernel=(5,5), channels=256, convStride=(4,4)) ->
Lrn(nsize=5, alpha=0.0001, beta=0.75) ->
conv(filter=(3,3), channels=384, hasPool=false) ->
conv(filter=(3,3), channels=384, hasPool=false) ->
conv(filter=(3,3), channels=256) ->
conv(kernel=(3,3), channels=384, hasPool=false) ->
conv(kernel=(3,3), channels=384, hasPool=false) ->
conv(kernel=(3,3), channels=256) ->
fc() ->
fc() ->
FullyConnected(units=classes) ->
Softmax() ->
softmax
predictions
}
......@@ -5,28 +5,28 @@ architecture ThreeInputCNN_M14(img_height=200, img_width=300, img_channels=3, cl
*Year: 2017*/
def input Z(0:255)^{img_channels, img_height, img_width} data[3]
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def conv(filter, channels){
Convolution(kernel=filter, channels=channels) ->
def conv(kernel, channels){
Convolution(kernel=kernel, channels=channels) ->
Relu()
}
def inputGroup(index){
[index] ->
conv(filter=(3,3), channels=32, ->=3) ->
conv(kernel=(3,3), channels=32, ->=3) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2))
}
data ->
inputGroup(index=0|..|2) ->
inputGroup(index=[0|..|2]) ->
Concatenate() ->
conv(filter=(3,3), channels=64) ->
conv(kernel=(3,3), channels=64) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
FullyConnected(units=32) ->
Relu() ->
FullyConnected(units=classes) ->
Softmax() ->
softmax
predictions
}
\ No newline at end of file
architecture VGG16(img_height=224, img_width=224, img_channels=3, classes=1000){
def input Z(0:255)^{img_channels, img_height, img_width} data
def output Q(0:1)^{classes} softmax
def output Q(0:1)^{classes} predictions
def conv(filter, channels){
Convolution(kernel=(filter,filter), channels=channels) ->
def conv(kernel, channels){
Convolution(kernel=(kernel,kernel), channels=channels) ->
Relu()
}
def fc(){
......@@ -13,19 +13,19 @@ architecture VGG16(img_height=224, img_width=224, img_channels=3, classes=1000){
}
data ->
conv(filter=3, channels=64, ->=2) ->
conv(kernel=3, channels=64, ->=2) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
conv(filter=3, channels=128, ->=2) ->
conv(kernel=3, channels=128, ->=2) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
conv(filter=3, channels=256, ->=3) ->
conv(kernel=3, channels=256, ->=3) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
conv(filter=3, channels=512, ->=3) ->
conv(kernel=3, channels=512, ->=3) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
conv(filter=3, channels=512, ->=3) ->
conv(kernel=3, channels=512, ->=3) ->
Pooling(pool_type="max", kernel=(2,2), stride=(2,2)) ->
fc() ->
fc() ->
FullyConnected(units=classes) ->
Softmax() ->
softmax
predictions
}
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest1(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest1(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest1(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2)) ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest2(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest2(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest2(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2)) ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest3(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest3(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest3(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding="valid") ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest4(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest4(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest4(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding=1) ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest5(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest5(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest5(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->
Pooling(pool_type="max", kernel=(3,3), stride=(2,2), padding="same") ->
resLayer(channels=64, ->=3) ->
resLayer(channels=128, stride=2) ->
......
......@@ -2,8 +2,8 @@ architecture ArgumentConstraintTest6(img_height=224, img_width=224, img_channels
def input Z(0:255)^{img_channels, img_height, img_width} image
def output Q(0:1)^{classes} predictions
def conv(filter, channels, stride=1, act=true){
Convolution(kernel=(filter,filter), channels=channels, stride=(stride,stride)) ->
def conv(kernel, channels, stride=1, act=true){
Convolution(kernel=(kernel,kernel), channels=channels, stride=(stride,stride)) ->
BatchNorm() ->
Relu(?=act)
}
......@@ -13,8 +13,8 @@ architecture ArgumentConstraintTest6(img_height=224, img_width=224, img_channels
}
def resLayer(channels, stride=1){
(
conv(filter=3, channels=channels, stride=stride) ->
conv(filter=3, channels=channels, stride=stride, act=false)
conv(kernel=3, channels=channels, stride=stride) ->
conv(kernel=3, channels=channels, stride=stride, act=false)
|
skip(channels=channels, stride=stride, ?=(stride!=1))
) ->
......@@ -23,7 +23,7 @@ architecture ArgumentConstraintTest6(img_height=224, img_width=224, img_channels
}
image ->
conv(filter=7, channels=64, stride=2) ->
conv(kernel=7, channels=64, stride=2) ->