Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
CNNTrainLang
Commits
7ff494bf
Commit
7ff494bf
authored
Jul 19, 2019
by
Nicola Gatto
Browse files
Add check critic network
parent
37e759d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CNNTrainCocos.java
View file @
7ff494bf
...
...
@@ -22,6 +22,7 @@ package de.monticore.lang.monticar.cnntrain._cocos;
import
de.monticore.lang.monticar.cnntrain._ast.ASTCNNTrainNode
;
import
de.monticore.lang.monticar.cnntrain._symboltable.CNNTrainCompilationUnitSymbol
;
import
de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol
;
import
de.se_rwth.commons.logging.Log
;
public
class
CNNTrainCocos
{
...
...
@@ -46,4 +47,11 @@ public class CNNTrainCocos {
int
findings
=
Log
.
getFindings
().
size
();
createChecker
().
checkAll
(
node
);
}
public
static
void
checkCriticCocos
(
final
ConfigurationSymbol
configurationSymbol
)
{
CNNTrainConfigurationSymbolChecker
checker
=
new
CNNTrainConfigurationSymbolChecker
()
.
addCoCo
(
new
CheckCriticNetworkHasExactlyAOneDimensionalOutput
());
int
findings
=
Log
.
getFindings
().
size
();
checker
.
checkAll
(
configurationSymbol
);
}
}
\ No newline at end of file
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CheckCriticNetworkHasExactlyAOneDimensionalOutput.java
0 → 100644
View file @
7ff494bf
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package
de.monticore.lang.monticar.cnntrain._cocos
;
import
de.monticore.lang.monticar.cnntrain._symboltable.ConfigurationSymbol
;
import
de.monticore.lang.monticar.cnntrain._symboltable.NNArchitectureSymbol
;
import
de.monticore.lang.monticar.cnntrain.helper.ErrorCodes
;
import
de.se_rwth.commons.logging.Log
;
import
java.util.List
;
/**
*
*/
public
class
CheckCriticNetworkHasExactlyAOneDimensionalOutput
implements
CNNTrainConfigurationSymbolCoCo
{
@Override
public
void
check
(
ConfigurationSymbol
configurationSymbol
)
{
if
(
configurationSymbol
.
getCriticNetwork
().
isPresent
())
{
NNArchitectureSymbol
criticNetwork
=
configurationSymbol
.
getCriticNetwork
().
get
();
if
(
criticNetwork
.
getOutputs
().
size
()
>
1
)
{
Log
.
error
(
"0"
+
ErrorCodes
.
CRITIC_NETWORK_ERROR
+
" The critic network has more than one outputs"
,
criticNetwork
.
getSourcePosition
());
}
final
String
outputName
=
criticNetwork
.
getOutputs
().
get
(
0
);
List
<
Integer
>
dimensions
=
criticNetwork
.
getDimensions
().
get
(
outputName
);
if
(
dimensions
.
size
()
!=
1
||
dimensions
.
get
(
0
)
!=
1
)
{
Log
.
error
(
"0"
+
ErrorCodes
.
CRITIC_NETWORK_ERROR
+
" The output "
+
outputName
+
" of critic network is not a one-dimensional vector"
,
configurationSymbol
.
getSourcePosition
());
}
}
}
}
src/main/java/de/monticore/lang/monticar/cnntrain/helper/ErrorCodes.java
View file @
7ff494bf
...
...
@@ -31,4 +31,5 @@ public class ErrorCodes {
public
static
final
String
REQUIRED_PARAMETER_MISSING
=
"xC8856"
;
public
static
final
String
STRATEGY_NOT_APPLICABLE
=
"xC8857"
;
public
static
final
String
CONTRADICTING_PARAMETERS
=
"xC8858"
;
public
static
final
String
CRITIC_NETWORK_ERROR
=
"xC7100"
;
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment