Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
cm3Libraries
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm3
cm3Libraries
Commits
dab5940c
Commit
dab5940c
authored
5 years ago
by
Van Dung NGUYEN
Browse files
Options
Downloads
Patches
Plain Diff
get new layers
parent
4c8ab939
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
NonLinearSolver/modelReduction/ANNUtils.cpp
+22
-0
22 additions, 0 deletions
NonLinearSolver/modelReduction/ANNUtils.cpp
NonLinearSolver/modelReduction/ANNUtils.h
+28
-1
28 additions, 1 deletion
NonLinearSolver/modelReduction/ANNUtils.h
with
50 additions
and
1 deletion
NonLinearSolver/modelReduction/ANNUtils.cpp
+
22
−
0
View file @
dab5940c
...
@@ -113,6 +113,26 @@ void DenseLayer::predict(const fullMatrix<double>& y0, fullMatrix<double>& y1, b
...
@@ -113,6 +113,26 @@ void DenseLayer::predict(const fullMatrix<double>& y0, fullMatrix<double>& y1, b
}
}
};
};
ReluDenseLayer
::
ReluDenseLayer
(
int
numIn
,
int
numOut
)
:
DenseLayer
(
numIn
,
numOut
)
{
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
activationFunc
=
new
ReluActivationFunction
();
}
ReluDenseLayer
::~
ReluDenseLayer
()
{
};
void
ReluDenseLayer
::
print_infos
()
const
{
printf
(
"relu dense layer: nbInput = %d, nbOutput=%d
\n
"
,
numInput
,
numOutput
);
}
DenseLayer
*
ReluDenseLayer
::
clone
()
const
{
return
new
ReluDenseLayer
(
*
this
);
}
LeakyReluDenseLayer
::
LeakyReluDenseLayer
(
int
numIn
,
int
numOut
,
double
a
)
:
DenseLayer
(
numIn
,
numOut
)
LeakyReluDenseLayer
::
LeakyReluDenseLayer
(
int
numIn
,
int
numOut
,
double
a
)
:
DenseLayer
(
numIn
,
numOut
)
{
{
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
...
@@ -201,6 +221,8 @@ void ArtificialNN::addLayer(int index, const DenseLayer& layer)
...
@@ -201,6 +221,8 @@ void ArtificialNN::addLayer(int index, const DenseLayer& layer)
{
{
// we add pointer to existing object instead of creating a new one
// we add pointer to existing object instead of creating a new one
_allLayers
[
index
]
=
layer
.
clone
();
_allLayers
[
index
]
=
layer
.
clone
();
Msg
::
Info
(
"add layer: %d"
,
index
);
_allLayers
[
index
]
->
print_infos
();
}
}
};
};
...
...
This diff is collapsed.
Click to expand it.
NonLinearSolver/modelReduction/ANNUtils.h
+
28
−
1
View file @
dab5940c
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
class
activationFunction
class
activationFunction
{
{
public:
public:
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
};
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
,
relu
=
3
};
public
:
public
:
activationFunction
(){}
activationFunction
(){}
activationFunction
(
const
activationFunction
&
src
){}
activationFunction
(
const
activationFunction
&
src
){}
...
@@ -52,6 +52,19 @@ class LeakyReluActivationFunction : public activationFunction
...
@@ -52,6 +52,19 @@ class LeakyReluActivationFunction : public activationFunction
virtual
double
getDiff
(
double
x
)
const
{
if
(
x
>=
0
)
return
1
;
else
return
alpha
;};
virtual
double
getDiff
(
double
x
)
const
{
if
(
x
>=
0
)
return
1
;
else
return
alpha
;};
virtual
activationFunction
*
clone
()
const
{
return
new
LeakyReluActivationFunction
(
*
this
);};
virtual
activationFunction
*
clone
()
const
{
return
new
LeakyReluActivationFunction
(
*
this
);};
};
};
class
ReluActivationFunction
:
public
activationFunction
{
public:
ReluActivationFunction
(){}
ReluActivationFunction
(
const
ReluActivationFunction
&
src
)
:
activationFunction
(
src
){}
virtual
~
ReluActivationFunction
(){}
virtual
activationFunction
::
functionType
getType
()
const
{
return
activationFunction
::
relu
;};
virtual
double
getVal
(
double
x
)
const
{
if
(
x
>=
0
)
return
x
;
else
return
x
;};
virtual
double
getDiff
(
double
x
)
const
{
if
(
x
>=
0
)
return
1
;
else
return
0
;};
virtual
activationFunction
*
clone
()
const
{
return
new
ReluActivationFunction
(
*
this
);};
};
#endif //SWIG
#endif //SWIG
class
DenseLayer
class
DenseLayer
...
@@ -80,6 +93,20 @@ class DenseLayer
...
@@ -80,6 +93,20 @@ class DenseLayer
#endif //SWIG
#endif //SWIG
};
};
class
ReluDenseLayer
:
public
DenseLayer
{
public:
ReluDenseLayer
(
int
numIn
,
int
numOut
);
void
print_infos
()
const
;
#ifndef SWIG
ReluDenseLayer
(
const
ReluDenseLayer
&
src
)
:
DenseLayer
(
src
){}
virtual
~
ReluDenseLayer
();
virtual
DenseLayer
*
clone
()
const
;
#endif //SWIG
};
class
LeakyReluDenseLayer
:
public
DenseLayer
class
LeakyReluDenseLayer
:
public
DenseLayer
{
{
public:
public:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment