Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lib4neuro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MolDyn
lib4neuro
Commits
32b7bce3
Commit
32b7bce3
authored
6 years ago
by
Michal Kravcenko
Browse files
Options
Downloads
Patches
Plain Diff
commit before merge
parent
dccfbaaf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
4neuro.cbp
+31
-0
31 additions, 0 deletions
4neuro.cbp
Makefile
+14
-0
14 additions, 0 deletions
Makefile
src/net_test_ode_1.cpp
+110
-3
110 additions, 3 deletions
src/net_test_ode_1.cpp
with
155 additions
and
3 deletions
4neuro.cbp
+
31
−
0
View file @
32b7bce3
...
...
@@ -625,6 +625,34 @@
<DistClean
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 clean"
/>
</MakeCommands>
</Target>
<Target
title=
"NeuralNetworkSum_test"
>
<Option
output=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/bin/unit-tests/NeuralNetworkSum_test"
prefix_auto=
"0"
extension_auto=
"0"
/>
<Option
working_dir=
"bin/unit-tests"
/>
<Option
object_output=
"./"
/>
<Option
type=
"1"
/>
<Option
compiler=
"gcc"
/>
<Compiler/>
<MakeCommands>
<Build
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 NeuralNetworkSum_test"
/>
<CompileFile
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 "$file""
/>
<Clean
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 clean"
/>
<DistClean
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 clean"
/>
</MakeCommands>
</Target>
<Target
title=
"NeuralNetworkSum_test/fast"
>
<Option
output=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/bin/unit-tests/NeuralNetworkSum_test"
prefix_auto=
"0"
extension_auto=
"0"
/>
<Option
working_dir=
"bin/unit-tests"
/>
<Option
object_output=
"./"
/>
<Option
type=
"1"
/>
<Option
compiler=
"gcc"
/>
<Compiler/>
<MakeCommands>
<Build
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 NeuralNetworkSum_test/fast"
/>
<CompileFile
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 "$file""
/>
<Clean
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 clean"
/>
<DistClean
command=
"/usr/bin/make -f "/home/fluffymoo/4NEURO_BIATCH/4Neuro/build/Makefile" VERBOSE=1 clean"
/>
</MakeCommands>
</Target>
</Build>
<Unit
filename=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/src/DataSet/DataSet.cpp"
>
<Option
target=
"4neuro"
/>
...
...
@@ -752,6 +780,9 @@
<Unit
filename=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/src/tests/ErrorFunctions_test.cpp"
>
<Option
target=
"errorfunction_test"
/>
</Unit>
<Unit
filename=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/src/tests/NeuralNetworkSum_test.cpp"
>
<Option
target=
"NeuralNetworkSum_test"
/>
</Unit>
<Unit
filename=
"/home/fluffymoo/4NEURO_BIATCH/4Neuro/src/tests/NeuralNetwork_test.cpp"
>
<Option
target=
"neural_network_test"
/>
</Unit>
...
...
This diff is collapsed.
Click to expand it.
Makefile
+
14
−
0
View file @
32b7bce3
...
...
@@ -383,6 +383,19 @@ particle_test/fast:
$(
MAKE
)
-f
build/CMakeFiles/particle_test.dir/build.make build/CMakeFiles/particle_test.dir/build
.PHONY
:
particle_test/fast
#=============================================================================
# Target rules for targets named NeuralNetworkSum_test
# Build rule for target.
NeuralNetworkSum_test
:
cmake_check_build_system
$(
MAKE
)
-f
CMakeFiles/Makefile2 NeuralNetworkSum_test
.PHONY
:
NeuralNetworkSum_test
# fast build rule for target.
NeuralNetworkSum_test/fast
:
$(
MAKE
)
-f
build/CMakeFiles/NeuralNetworkSum_test.dir/build.make build/CMakeFiles/NeuralNetworkSum_test.dir/build
.PHONY
:
NeuralNetworkSum_test/fast
# Help Target
help
:
@
echo
"The following are some of the valid targets for this Makefile:"
...
...
@@ -412,6 +425,7 @@ help:
@
echo
"... errorfunction_test"
@
echo
"... linear_neuron_test"
@
echo
"... particle_test"
@
echo
"... NeuralNetworkSum_test"
.PHONY
:
help
...
...
This diff is collapsed.
Click to expand it.
src/net_test_ode_1.cpp
+
110
−
3
View file @
32b7bce3
...
...
@@ -5,20 +5,104 @@
* y(0) = 1
* (d/dt)y(0) = 1
*
* -------------------------------------------
* Analytical solution: e^(-2x) * (3x + 1)
*
* @author Michal Kravčenko
* @date 17.7.18 -
*/
#include
<random>
#include
<vector>
#include
<utility>
#include
<iostream>
#include
"../include/4neuro.h"
#include
"Solvers/DESolver.h"
int
main
()
{
void
test_analytical_gradient_y
(
unsigned
int
n_inner_neurons
)
{
unsigned
int
n_inputs
=
1
;
}
void
test_analytical_y
(
unsigned
int
n_inner_neurons
){
unsigned
int
n_inputs
=
1
;
unsigned
int
n_outputs
=
1
;
unsigned
int
n_equations
=
1
;
/* SETUP OF THE TRAINING DATA */
std
::
vector
<
double
>
inp
,
out
;
double
d1_s
=
0.0
,
d1_e
=
1.0
,
frac
,
alpha
,
x
;
/* TRAIN DATA FOR THE GOVERNING DE */
std
::
vector
<
std
::
pair
<
std
::
vector
<
double
>
,
std
::
vector
<
double
>>>
data_vec_g
;
unsigned
int
train_size
=
150
;
/* ISOTROPIC TRAIN SET */
frac
=
(
d1_e
-
d1_s
)
/
(
train_size
-
1
);
// for(unsigned int i = 0; i < train_size; ++i){
// x = frac * i;
// inp = {x};
// out = {std::pow(E, -2 * x) * (3 * x + 1)};
// data_vec_g.emplace_back(std::make_pair(inp, out));
//
// std::cout << i + 1 << " " << x << " " << out[0] << std::endl;
// }
/* CHEBYSCHEV TRAIN SET */
alpha
=
PI
/
(
train_size
-
1
);
frac
=
0.5
*
(
d1_e
-
d1_s
);
for
(
unsigned
int
i
=
0
;
i
<
train_size
;
++
i
){
x
=
(
std
::
cos
(
PI
-
alpha
*
i
)
+
1.0
)
*
frac
+
d1_s
;
inp
=
{
x
};
out
=
{
std
::
pow
(
E
,
-
2
*
x
)
*
(
3
*
x
+
1
)};
data_vec_g
.
emplace_back
(
std
::
make_pair
(
inp
,
out
));
std
::
cout
<<
i
+
1
<<
" "
<<
x
<<
" "
<<
out
[
0
]
<<
std
::
endl
;
}
DataSet
ds_00
(
&
data_vec_g
);
// return;
DESolver
solver_01
(
n_equations
,
n_inputs
,
n_inner_neurons
,
n_outputs
);
NeuralNetwork
*
solution
=
solver_01
.
get_solution
();
/* PARTICLE SWARM TRAINING METHOD SETUP */
unsigned
int
max_iters
=
150
;
//must encapsulate each of the partial error functions
double
*
domain_bounds
=
new
double
[
2
*
n_inner_neurons
*
(
n_inputs
+
n_outputs
)
];
for
(
unsigned
int
i
=
0
;
i
<
n_inner_neurons
*
(
n_inputs
+
n_outputs
);
++
i
){
domain_bounds
[
2
*
i
]
=
-
800.0
;
domain_bounds
[
2
*
i
+
1
]
=
800.0
;
}
double
c1
=
0.5
,
c2
=
0.8
,
w
=
0.8
;
unsigned
int
n_particles
=
100
;
double
gamma
=
0.5
,
epsilon
=
0.001
,
delta
=
0.9
;
MSE
mse
(
solution
,
&
ds_00
);
ParticleSwarm
swarm_01
(
&
mse
,
domain_bounds
,
c1
,
c2
,
w
,
n_particles
,
max_iters
);
swarm_01
.
optimize
(
gamma
,
epsilon
,
delta
);
unsigned
int
n_test_points
=
100
;
std
::
vector
<
double
>
input
(
1
),
output
(
1
);
double
error
=
0.0
;
for
(
unsigned
int
i
=
0
;
i
<
n_test_points
;
++
i
){
input
[
0
]
=
i
*
((
d1_e
-
d1_s
)
/
(
n_test_points
-
1
))
+
d1_s
;
solution
->
eval_single
(
input
,
output
);
std
::
cout
<<
i
+
1
<<
" "
<<
std
::
abs
(
output
[
0
]
-
std
::
pow
(
E
,
-
2
*
input
[
0
])
*
(
3
*
input
[
0
]
+
1
))
<<
" "
<<
output
[
0
]
<<
std
::
endl
;
}
delete
[]
domain_bounds
;
}
void
test_odr
(
unsigned
int
n_inner_neurons
){
unsigned
int
n_inputs
=
1
;
unsigned
int
n_inner_neurons
=
4
;
unsigned
int
n_outputs
=
1
;
unsigned
int
n_equations
=
3
;
...
...
@@ -118,7 +202,30 @@ int main() {
NeuralNetwork
*
solution
=
solver_01
.
get_solution
();
unsigned
int
n_test_points
=
100
;
std
::
vector
<
double
>
input
(
1
),
output
(
1
);
for
(
unsigned
int
i
=
0
;
i
<
n_test_points
;
++
i
){
input
[
0
]
=
i
*
((
d1_e
-
d1_s
)
/
(
n_test_points
-
1
))
+
d1_s
;
solution
->
eval_single
(
input
,
output
);
std
::
cout
<<
i
+
1
<<
" "
<<
output
[
0
]
<<
std
::
endl
;
}
delete
[]
domain_bounds
;
}
int
main
()
{
unsigned
int
n_inner_neurons
=
20
;
// test_odr(n_inner_neurons);
test_analytical_y
(
n_inner_neurons
);
test_analytical_gradient_y
(
n_inner_neurons
);
return
0
;
}
\ No newline at end of file
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