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
b3593161
Commit
b3593161
authored
5 years ago
by
Van Dung NGUYEN
Browse files
Options
Downloads
Patches
Plain Diff
add tanh ANN layer
parent
d5e1e3b6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
NonLinearSolver/modelReduction/ANNUtils.cpp
+19
-0
19 additions, 0 deletions
NonLinearSolver/modelReduction/ANNUtils.cpp
NonLinearSolver/modelReduction/ANNUtils.h
+25
-2
25 additions, 2 deletions
NonLinearSolver/modelReduction/ANNUtils.h
with
44 additions
and
2 deletions
NonLinearSolver/modelReduction/ANNUtils.cpp
+
19
−
0
View file @
b3593161
...
...
@@ -133,6 +133,25 @@ DenseLayer* ReluDenseLayer::clone() const
}
TanhDenseLayer
::
TanhDenseLayer
(
int
numIn
,
int
numOut
)
:
DenseLayer
(
numIn
,
numOut
)
{
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
activationFunc
=
new
TanhActivationFunction
();
}
TanhDenseLayer
::~
TanhDenseLayer
()
{
};
void
TanhDenseLayer
::
print_infos
()
const
{
printf
(
"tanh dense layer: nbInput = %d, nbOutput=%d
\n
"
,
numInput
,
numOutput
);
}
DenseLayer
*
TanhDenseLayer
::
clone
()
const
{
return
new
TanhDenseLayer
(
*
this
);
}
LeakyReluDenseLayer
::
LeakyReluDenseLayer
(
int
numIn
,
int
numOut
,
double
a
)
:
DenseLayer
(
numIn
,
numOut
)
{
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
...
...
This diff is collapsed.
Click to expand it.
NonLinearSolver/modelReduction/ANNUtils.h
+
25
−
2
View file @
b3593161
...
...
@@ -11,11 +11,12 @@
#define ANNUTILS_H_
#ifndef SWIG
#include
"fullMatrix.h"
#include
<math.h>
class
activationFunction
{
public:
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
,
relu
=
3
};
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
,
relu
=
3
,
tanHyperbolic
=
4
};
public
:
activationFunction
(){}
activationFunction
(
const
activationFunction
&
src
){}
...
...
@@ -38,6 +39,18 @@ class LinearActivationFunction: public activationFunction
virtual
activationFunction
*
clone
()
const
{
return
new
LinearActivationFunction
(
*
this
);};
};
class
TanhActivationFunction
:
public
activationFunction
{
public:
TanhActivationFunction
(){}
TanhActivationFunction
(
const
TanhActivationFunction
&
src
)
:
activationFunction
(
src
){}
virtual
~
TanhActivationFunction
(){}
virtual
activationFunction
::
functionType
getType
()
const
{
return
activationFunction
::
tanHyperbolic
;};
virtual
double
getVal
(
double
x
)
const
{
return
tanh
(
x
);};
virtual
double
getDiff
(
double
x
)
const
{
return
1.
-
x
*
x
;};
virtual
activationFunction
*
clone
()
const
{
return
new
TanhActivationFunction
(
*
this
);};
};
class
LeakyReluActivationFunction
:
public
activationFunction
{
protected:
...
...
@@ -104,7 +117,17 @@ class ReluDenseLayer : public DenseLayer
#endif //SWIG
};
class
TanhDenseLayer
:
public
DenseLayer
{
public:
TanhDenseLayer
(
int
numIn
,
int
numOut
);
virtual
void
print_infos
()
const
;
#ifndef SWIG
TanhDenseLayer
(
const
TanhDenseLayer
&
src
)
:
DenseLayer
(
src
){}
virtual
~
TanhDenseLayer
();
virtual
DenseLayer
*
clone
()
const
;
#endif //SWIG
};
class
LeakyReluDenseLayer
:
public
DenseLayer
{
...
...
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