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
4f0a3de1
Commit
4f0a3de1
authored
5 years ago
by
Van Dung NGUYEN
Browse files
Options
Downloads
Patches
Plain Diff
add new ann layer
parent
db204fc2
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
+27
-2
27 additions, 2 deletions
NonLinearSolver/modelReduction/ANNUtils.h
with
46 additions
and
2 deletions
NonLinearSolver/modelReduction/ANNUtils.cpp
+
19
−
0
View file @
4f0a3de1
...
@@ -152,6 +152,25 @@ DenseLayer* TanhDenseLayer::clone() const
...
@@ -152,6 +152,25 @@ DenseLayer* TanhDenseLayer::clone() const
return
new
TanhDenseLayer
(
*
this
);
return
new
TanhDenseLayer
(
*
this
);
}
}
SigmoidDenseLayer
::
SigmoidDenseLayer
(
int
numIn
,
int
numOut
)
:
DenseLayer
(
numIn
,
numOut
)
{
if
(
activationFunc
!=
NULL
)
delete
activationFunc
;
activationFunc
=
new
SigmoidActivationFunction
();
}
SigmoidDenseLayer
::~
SigmoidDenseLayer
()
{
};
void
SigmoidDenseLayer
::
print_infos
()
const
{
printf
(
"sigmoid dense layer: nbInput = %d, nbOutput=%d
\n
"
,
numInput
,
numOutput
);
}
DenseLayer
*
SigmoidDenseLayer
::
clone
()
const
{
return
new
SigmoidDenseLayer
(
*
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
;
...
...
This diff is collapsed.
Click to expand it.
NonLinearSolver/modelReduction/ANNUtils.h
+
27
−
2
View file @
4f0a3de1
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
class
activationFunction
class
activationFunction
{
{
public:
public:
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
,
relu
=
3
,
tanHyperbolic
=
4
};
enum
functionType
{
undef
=
0
,
linear
=
1
,
leakyRelu
=
2
,
relu
=
3
,
tanHyperbolic
=
4
,
sigmoid
=
5
};
public
:
public
:
activationFunction
(){}
activationFunction
(){}
activationFunction
(
const
activationFunction
&
src
){}
activationFunction
(
const
activationFunction
&
src
){}
...
@@ -47,10 +47,23 @@ class TanhActivationFunction: public activationFunction
...
@@ -47,10 +47,23 @@ class TanhActivationFunction: public activationFunction
virtual
~
TanhActivationFunction
(){}
virtual
~
TanhActivationFunction
(){}
virtual
activationFunction
::
functionType
getType
()
const
{
return
activationFunction
::
tanHyperbolic
;};
virtual
activationFunction
::
functionType
getType
()
const
{
return
activationFunction
::
tanHyperbolic
;};
virtual
double
getVal
(
double
x
)
const
{
return
tanh
(
x
);};
virtual
double
getVal
(
double
x
)
const
{
return
tanh
(
x
);};
virtual
double
getDiff
(
double
x
)
const
{
return
1.
-
x
*
x
;};
virtual
double
getDiff
(
double
x
)
const
{
return
1.
-
tanh
(
x
)
*
tanh
(
x
)
;};
virtual
activationFunction
*
clone
()
const
{
return
new
TanhActivationFunction
(
*
this
);};
virtual
activationFunction
*
clone
()
const
{
return
new
TanhActivationFunction
(
*
this
);};
};
};
class
SigmoidActivationFunction
:
public
activationFunction
{
public:
SigmoidActivationFunction
(){}
SigmoidActivationFunction
(
const
SigmoidActivationFunction
&
src
)
:
activationFunction
(
src
){}
virtual
~
SigmoidActivationFunction
(){}
virtual
activationFunction
::
functionType
getType
()
const
{
return
activationFunction
::
sigmoid
;};
virtual
double
getVal
(
double
x
)
const
{
return
1.
/
(
1.
+
exp
(
-
x
));};
virtual
double
getDiff
(
double
x
)
const
{
return
exp
(
x
)
/
(
1.
+
exp
(
x
))
/
(
1.
+
exp
(
x
));};
virtual
activationFunction
*
clone
()
const
{
return
new
SigmoidActivationFunction
(
*
this
);};
};
class
LeakyReluActivationFunction
:
public
activationFunction
class
LeakyReluActivationFunction
:
public
activationFunction
{
{
protected:
protected:
...
@@ -129,6 +142,18 @@ class TanhDenseLayer : public DenseLayer
...
@@ -129,6 +142,18 @@ class TanhDenseLayer : public DenseLayer
#endif //SWIG
#endif //SWIG
};
};
class
SigmoidDenseLayer
:
public
DenseLayer
{
public:
SigmoidDenseLayer
(
int
numIn
,
int
numOut
);
virtual
void
print_infos
()
const
;
#ifndef SWIG
SigmoidDenseLayer
(
const
SigmoidDenseLayer
&
src
)
:
DenseLayer
(
src
){}
virtual
~
SigmoidDenseLayer
();
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