Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNTrainLang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
languages
CNNTrainLang
Commits
300c11a6
Commit
300c11a6
authored
Nov 11, 2019
by
Julian Dierkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beginning to add support for GAN
parent
dc20415c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
170 additions
and
24 deletions
+170
-24
cnntrainlang.log
cnntrainlang.log
+14
-0
src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4
src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4
+18
-1
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CheckActorCriticRequiresCriticNetwork.java
...nntrain/_cocos/CheckActorCriticRequiresCriticNetwork.java
+3
-17
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CheckLearningParameterCombination.java
...ar/cnntrain/_cocos/CheckLearningParameterCombination.java
+7
-4
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java
...g/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java
+12
-2
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/CNNTrainSymbolTableCreator.java
...car/cnntrain/_symboltable/CNNTrainSymbolTableCreator.java
+46
-0
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/ConfigurationSymbol.java
...g/monticar/cnntrain/_symboltable/ConfigurationSymbol.java
+41
-0
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/LearningMethod.java
...e/lang/monticar/cnntrain/_symboltable/LearningMethod.java
+6
-0
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/NoiseDistribution.java
...ang/monticar/cnntrain/_symboltable/NoiseDistribution.java
+16
-0
src/main/java/de/monticore/lang/monticar/cnntrain/helper/ConfigEntryNameConstants.java
...ng/monticar/cnntrain/helper/ConfigEntryNameConstants.java
+7
-0
No files found.
cnntrainlang.log
0 → 100644
View file @
300c11a6
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< de.monticore.lang.monticar:cnn-train >----------------
[INFO] Building cnn-train 0.3.6-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cnn-train ---
[INFO] Deleting /home/julian/Dropbox/Dokumente/bachelorarbeit/pipeline/CNNTrainLang/target
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.1:prepare-agent (pre-unit-test) @ cnn-train ---
[INFO] argLine set to -javaagent:/home/julian/.m2/repository/org/jacoco/org.jacoco.agent/0.8.1/org.jacoco.agent-0.8.1-runtime.jar=destfile=/home/julian/Dropbox/Dokumente/bachelorarbeit/pipeline/CNNTrainLang/target/jacoco.exec
[INFO]
[INFO] --- monticore-maven-plugin:5.0.1:generate (default) @ cnn-train ---
[INFO] Changes detected for /home/julian/Dropbox/Dokumente/bachelorarbeit/pipeline/CNNTrainLang/src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4. Regenerating...
src/main/grammars/de/monticore/lang/monticar/CNNTrain.mc4
View file @
300c11a6
...
...
@@ -24,6 +24,7 @@ grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.Number
BooleanValue
implements
ConfigValue
=
(
TRUE
:
"true"
|
FALSE
:
"false"
);
ComponentNameValue
implements
ConfigValue
=
Name
(
"."
Name
)*;
DoubleVectorValue
implements
ConfigValue
=
"("
number
:
NumberWithUnit
(
","
number
:
NumberWithUnit
)*
")"
;
IntegerTupelValue
implements
ConfigValue
=
"("
first
:
IntegerValue
","
second
:
IntegerValue
")"
;
NumEpochEntry
implements
ConfigEntry
=
name
:
"num_epoch"
":"
value
:
IntegerValue
;
BatchSizeEntry
implements
ConfigEntry
=
name
:
"batch_size"
":"
value
:
IntegerValue
;
...
...
@@ -147,7 +148,7 @@ grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.Number
StartTrainingAtEntry
implements
ConfigEntry
=
name
:
"start_training_at"
":"
value
:
IntegerValue
;
EvaluationSamplesEntry
implements
ConfigEntry
=
name
:
"evaluation_samples"
":"
value
:
IntegerValue
;
LearningMethodValue
implements
ConfigValue
=
(
supervisedLearning
:
"supervised"
|
reinforcement
:
"reinforcement"
);
LearningMethodValue
implements
ConfigValue
=
(
supervisedLearning
:
"supervised"
|
reinforcement
:
"reinforcement"
|
gan
:
"gan"
);
RLAlgorithmValue
implements
ConfigValue
=
(
dqn
:
"dqn-algorithm"
|
ddpg
:
"ddpg-algorithm"
|
tdThree
:
"td3-algorithm"
);
...
...
@@ -230,4 +231,20 @@ grammar CNNTrain extends de.monticore.lang.monticar.Common2, de.monticore.Number
PolicyNoiseEntry
implements
ConfigEntry
=
name
:
"policy_noise"
":"
value
:
NumberValue
;
NoiseClipEntry
implements
ConfigEntry
=
name
:
"noise_clip"
":"
value
:
NumberValue
;
PolicyDelayEntry
implements
ConfigEntry
=
name
:
"policy_delay"
":"
value
:
IntegerValue
;
//
GANs
Extensions
DiscriminatorNetworkEntry
implements
ConfigEntry
=
name
:
"discriminator_name"
":"
value
:
ComponentNameValue
;
PreprocessingEntry
implements
ConfigEntry
=
name
:
"preprocessing_name"
":"
value
:
ComponentNameValue
;
ImgResizeEntry
implements
ConfigEntry
=
name
:
"img_resize"
":"
value
:
IntegerTupelValue
;
//
Noise
Distribution
Creator
NoiseDistributionEntry
implements
MultiParamConfigEntry
=
name
:
"noise_distribution"
":"
value
:
NoiseDistributionValue
;
interface
NoiseDistributionValue
extends
MultiParamValue
;
interface
NoiseDistributionGaussianEntry
extends
Entry
;
NoiseDistributionGaussianValue
implements
NoiseDistributionValue
=
name
:
"gaussian"
(
"{"
params
:
NoiseDistributionGaussianEntry
*
"}"
)?;
MeanValueEntry
implements
NoiseDistributionGaussianEntry
=
name
:
"mean_value"
":"
value
:
IntegerValue
;
SpreadValueEntry
implements
NoiseDistributionGaussianEntry
=
name
:
"spread_value"
":"
value
:
IntegerValue
;
}
\ No newline at end of file
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CheckActorCriticRequiresCriticNetwork.java
View file @
300c11a6
/**
* (c) https://github.com/MontiCore/monticore
*
* ******************************************************************************
* 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/>.
* *******************************************************************************
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package
de.monticore.lang.monticar.cnntrain._cocos
;
...
...
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/CheckLearningParameterCombination.java
View file @
300c11a6
...
...
@@ -59,10 +59,9 @@ public class CheckLearningParameterCombination implements CNNTrainASTEntryCoCo {
if
(
supervisedLearningParameter
&&
!
reinforcementLearningParameter
)
{
setLearningMethodOrLogErrorIfActualLearningMethodIsNotSupervised
(
node
);
}
else
if
(!
supervisedLearningParameter
)
{
}
else
if
(!
supervisedLearningParameter
&&
reinforcementLearningParameter
)
{
setLearningMethodOrLogErrorIfActualLearningMethodIsNotReinforcement
(
node
);
}
}
private
void
setLearningMethodOrLogErrorIfActualLearningMethodIsNotReinforcement
(
ASTEntry
node
)
{
...
...
@@ -91,8 +90,12 @@ public class CheckLearningParameterCombination implements CNNTrainASTEntryCoCo {
private
void
evaluateLearningMethodEntry
(
ASTEntry
node
)
{
ASTLearningMethodValue
learningMethodValue
=
(
ASTLearningMethodValue
)
node
.
getValue
();
LearningMethod
evaluatedLearningMethod
=
learningMethodValue
.
isPresentReinforcement
()
?
LearningMethod
.
REINFORCEMENT
:
LearningMethod
.
SUPERVISED
;
LearningMethod
evaluatedLearningMethod
;
if
(
learningMethodValue
.
isPresentReinforcement
())
{
evaluatedLearningMethod
=
LearningMethod
.
REINFORCEMENT
;
}
else
{
evaluatedLearningMethod
=
LearningMethod
.
SUPERVISED
;
}
if
(
isLearningMethodKnown
())
{
logErrorIfEvaluatedLearningMethoNotEqualToActual
(
node
,
evaluatedLearningMethod
);
...
...
src/main/java/de/monticore/lang/monticar/cnntrain/_cocos/ParameterAlgorithmMapping.java
View file @
300c11a6
...
...
@@ -46,7 +46,8 @@ class ParameterAlgorithmMapping {
ASTFromLogitsEntry
.
class
,
ASTMarginEntry
.
class
,
ASTLabelFormatEntry
.
class
,
ASTRhoEntry
.
class
ASTRhoEntry
.
class
,
ASTPreprocessingEntry
.
class
);
private
static
final
List
<
Class
>
GENERAL_REINFORCEMENT_PARAMETERS
=
Lists
.
newArrayList
(
...
...
@@ -110,6 +111,12 @@ class ParameterAlgorithmMapping {
ASTStrategyGaussianNoiseVarianceEntry
.
class
);
private
static
final
List
<
Class
>
GENERAL_GAN_PARAMETERS
=
Lists
.
newArrayList
(
ASTDiscriminatorNetworkEntry
.
class
,
ASTNoiseDistributionEntry
.
class
,
ASTImgResizeEntry
.
class
);
ParameterAlgorithmMapping
()
{
}
...
...
@@ -124,7 +131,9 @@ class ParameterAlgorithmMapping {
boolean
isSupervisedLearningParameter
(
Class
<?
extends
ASTEntry
>
entryClazz
)
{
return
GENERAL_PARAMETERS
.
contains
(
entryClazz
)
||
EXCLUSIVE_SUPERVISED_PARAMETERS
.
contains
(
entryClazz
);
||
EXCLUSIVE_SUPERVISED_PARAMETERS
.
contains
(
entryClazz
)
||
GENERAL_GAN_PARAMETERS
.
contains
(
entryClazz
);
}
boolean
isDqnParameter
(
Class
<?
extends
ASTEntry
>
entryClazz
)
{
...
...
@@ -159,6 +168,7 @@ class ParameterAlgorithmMapping {
return
ImmutableList
.<
Class
>
builder
()
.
addAll
(
GENERAL_PARAMETERS
)
.
addAll
(
EXCLUSIVE_SUPERVISED_PARAMETERS
)
.
addAll
(
GENERAL_GAN_PARAMETERS
)
.
build
();
}
}
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/CNNTrainSymbolTableCreator.java
View file @
300c11a6
...
...
@@ -344,6 +344,8 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
if
(
node
.
getValue
().
isPresentReinforcement
())
{
value
.
setValue
(
LearningMethod
.
REINFORCEMENT
);
}
if
(
node
.
getValue
().
isPresentGan
())
{
value
.
setValue
(
LearningMethod
.
GAN
);
}
else
if
(
node
.
getValue
().
isPresentSupervisedLearning
())
{
value
.
setValue
(
LearningMethod
.
SUPERVISED
);
}
...
...
@@ -459,7 +461,35 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
configuration
.
getEntryMap
().
put
(
node
.
getName
(),
entry
);
}
@Override
public
void
visit
(
ASTDiscriminatorNetworkEntry
node
)
{
EntrySymbol
entry
=
new
EntrySymbol
(
node
.
getName
());
entry
.
setValue
(
getValueSymbolForComponentNameAsString
(
node
.
getValue
()));
addToScopeAndLinkWithNode
(
entry
,
node
);
configuration
.
getEntryMap
().
put
(
node
.
getName
(),
entry
);
}
@Override
public
void
visit
(
ASTPreprocessingEntry
node
)
{
EntrySymbol
entry
=
new
EntrySymbol
(
node
.
getName
());
entry
.
setValue
(
getValueSymbolForComponentNameAsString
(
node
.
getValue
()));
addToScopeAndLinkWithNode
(
entry
,
node
);
configuration
.
getEntryMap
().
put
(
node
.
getName
(),
entry
);
}
@Override
public
void
visit
(
ASTImgResizeEntry
node
)
{
EntrySymbol
width_entry
=
new
EntrySymbol
(
node
.
getName
());
EntrySymbol
height_entry
=
new
EntrySymbol
(
node
.
getName
());
width_entry
.
setValue
(
getValueSymbolForInteger
(
node
.
getValue
().
getFirst
()));
height_entry
.
setValue
(
getValueSymbolForInteger
(
node
.
getValue
().
getSecond
()));
addToScopeAndLinkWithNode
(
width_entry
,
node
);
addToScopeAndLinkWithNode
(
height_entry
,
node
);
configuration
.
getEntryMap
().
put
(
node
.
getName
()
+
"_width"
,
width_entry
);
configuration
.
getEntryMap
().
put
(
node
.
getName
()
+
"_height"
,
height_entry
);
}
@Override
public
void
visit
(
ASTReplayMemoryEntry
node
)
{
...
...
@@ -493,6 +523,22 @@ public class CNNTrainSymbolTableCreator extends CNNTrainSymbolTableCreatorTOP {
processMultiParamConfigEndVisit
(
node
);
}
@Override
public
void
visit
(
ASTNoiseDistributionEntry
node
)
{
NoiseDistribution
noiseDistribution
;
if
(
node
.
getValue
().
getName
().
equals
(
"gaussian"
))
{
noiseDistribution
=
NoiseDistribution
.
GAUSSIAN
;
}
else
{
noiseDistribution
=
NoiseDistribution
.
GAUSSIAN
;
}
processMultiParamConfigVisit
(
node
,
noiseDistribution
);
}
@Override
public
void
endVisit
(
ASTNoiseDistributionEntry
node
)
{
processMultiParamConfigEndVisit
(
node
);
}
@Override
public
void
visit
(
ASTRewardFunctionEntry
node
)
{
RewardFunctionSymbol
symbol
=
new
RewardFunctionSymbol
(
node
.
getName
());
...
...
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/ConfigurationSymbol.java
View file @
300c11a6
...
...
@@ -22,6 +22,7 @@ public class ConfigurationSymbol extends CommonScopeSpanningSymbol {
private
RewardFunctionSymbol
rlRewardFunctionSymbol
;
private
NNArchitectureSymbol
trainedArchitecture
;
private
NNArchitectureSymbol
criticNetwork
;
private
NNArchitectureSymbol
discriminatorNetwork
;
public
static
final
ConfigurationSymbolKind
KIND
=
new
ConfigurationSymbolKind
();
...
...
@@ -75,10 +76,18 @@ public class ConfigurationSymbol extends CommonScopeSpanningSymbol {
return
Optional
.
ofNullable
(
criticNetwork
);
}
public
Optional
<
NNArchitectureSymbol
>
getDiscriminatorNetwork
()
{
return
Optional
.
ofNullable
(
discriminatorNetwork
);
}
public
void
setCriticNetwork
(
NNArchitectureSymbol
criticNetwork
)
{
this
.
criticNetwork
=
criticNetwork
;
}
public
void
setDiscriminatorNetwork
(
NNArchitectureSymbol
discriminatorNetwork
)
{
this
.
discriminatorNetwork
=
discriminatorNetwork
;
}
public
Map
<
String
,
EntrySymbol
>
getEntryMap
()
{
return
entryMap
;
}
...
...
@@ -96,10 +105,22 @@ public class ConfigurationSymbol extends CommonScopeSpanningSymbol {
return
getLearningMethod
().
equals
(
LearningMethod
.
REINFORCEMENT
);
}
public
boolean
isGAN
()
{
return
getLearningMethod
().
equals
(
LearningMethod
.
GAN
);
}
public
boolean
hasPreprocessor
()
{
return
getEntryMap
().
containsKey
(
PREPROCESSING_NAME
);
}
public
boolean
hasCritic
()
{
return
getEntryMap
().
containsKey
(
CRITIC
);
}
public
boolean
hasDiscriminator
()
{
return
getEntryMap
().
containsKey
(
DISCRIMINATOR_NAME
);
}
public
Optional
<
String
>
getCriticName
()
{
if
(!
hasCritic
())
{
return
Optional
.
empty
();
...
...
@@ -109,4 +130,24 @@ public class ConfigurationSymbol extends CommonScopeSpanningSymbol {
assert
criticNameValue
instanceof
String
;
return
Optional
.
of
((
String
)
criticNameValue
);
}
public
Optional
<
String
>
getPreprocessingName
()
{
if
(!
hasPreprocessor
())
{
return
Optional
.
empty
();
}
final
Object
preprocessingNameValue
=
getEntry
(
PREPROCESSING_NAME
).
getValue
().
getValue
();
assert
preprocessingNameValue
instanceof
String
;
return
Optional
.
of
((
String
)
preprocessingNameValue
);
}
public
Optional
<
String
>
getDiscriminatorName
()
{
if
(!
hasDiscriminator
())
{
return
Optional
.
empty
();
}
final
Object
discriminatorNameValue
=
getEntry
(
DISCRIMINATOR_NAME
).
getValue
().
getValue
();
assert
discriminatorNameValue
instanceof
String
;
return
Optional
.
of
((
String
)
discriminatorNameValue
);
}
}
\ No newline at end of file
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/LearningMethod.java
View file @
300c11a6
...
...
@@ -22,5 +22,11 @@ public enum LearningMethod {
public
String
toString
()
{
return
"reinforcement"
;
}
},
GAN
{
@Override
public
String
toString
()
{
return
"gan"
;
}
}
}
src/main/java/de/monticore/lang/monticar/cnntrain/_symboltable/NoiseDistribution.java
0 → 100644
View file @
300c11a6
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
package
de.monticore.lang.monticar.cnntrain._symboltable
;
public
enum
NoiseDistribution
{
GAUSSIAN
{
@Override
public
String
toString
()
{
return
"gaussian"
;
}
}
}
src/main/java/de/monticore/lang/monticar/cnntrain/helper/ConfigEntryNameConstants.java
View file @
300c11a6
...
...
@@ -44,4 +44,11 @@ public class ConfigEntryNameConstants {
public
static
final
String
STRATEGY_EPSDECAY
=
"epsdecay"
;
public
static
final
String
CRITIC
=
"critic"
;
public
static
final
String
DISCRIMINATOR_NAME
=
"discriminator_name"
;
public
static
final
String
PREPROCESSING_NAME
=
"preprocessing_name"
;
public
static
final
String
NOISE_DISTRIBUTION
=
"noise_distribution"
;
public
static
final
String
IMG_RESIZE
=
"img_resize"
;
public
static
final
String
IMG_RESIZE_WIDTH
=
"img_resize_width"
;
public
static
final
String
IMG_RESIZE_HEIGHT
=
"img_resize_height"
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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