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
d6807dde
Commit
d6807dde
authored
6 years ago
by
Martin Beseda
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Separated neuron serialization example.
parent
db04445a
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
src/CMakeLists.txt
+3
-0
3 additions, 0 deletions
src/CMakeLists.txt
src/Neuron/Neuron.cpp
+1
-5
1 addition, 5 deletions
src/Neuron/Neuron.cpp
src/main.cpp
+2
-109
2 additions, 109 deletions
src/main.cpp
with
6 additions
and
114 deletions
src/CMakeLists.txt
+
3
−
0
View file @
d6807dde
...
...
@@ -37,6 +37,9 @@ target_link_libraries(data_set boost_serialization)
add_executable
(
test_cases main.cpp
)
target_link_libraries
(
test_cases neuron particle_swarm boost_serialization data_set
)
add_executable
(
neuron_serialization_example neuron_serialization_example.cpp
)
target_link_libraries
(
neuron_serialization_example neuron boost_serialization
)
##############
# UNIT TESTS #
##############
...
...
This diff is collapsed.
Click to expand it.
src/Neuron/Neuron.cpp
+
1
−
5
View file @
d6807dde
...
...
@@ -49,11 +49,7 @@ void Neuron::adjust_saturation_out(int value) {
bool
Neuron
::
is_saturated_out
()
{
if
(
this
->
n_saturated_connections_out
==
this
->
edges_out
->
size
()){
return
true
;
}
return
false
;
return
this
->
n_saturated_connections_out
==
this
->
edges_out
->
size
();
}
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
2
−
109
View file @
d6807dde
...
...
@@ -23,6 +23,8 @@
#include
"Neuron/NeuronTanh.h"
#include
"DataSet/DataSet.h"
//TODO rewrite "tests" to separate examples
//TODO prepsat tak, aby neuronova sit managovala destruktory vsech potrebnych objektu (kvuli serializaci)
/**
* Test of simple neural network
...
...
@@ -65,115 +67,6 @@ void test1( ){
delete
u2
;
}
/**
* Test of the binary serialization
*/
void
test2
()
{
NeuronLinear
n
(
2
,
3
);
std
::
cout
<<
n
.
get_potential
()
<<
" "
<<
n
.
get_state
()
<<
" "
<<
n
.
activation_function_get_parameter
(
0
)
<<
" "
<<
n
.
activation_function_get_parameter
(
1
)
<<
std
::
endl
;
std
::
ofstream
ofs
(
"stored_neuron.4n"
);
{
boost
::
archive
::
text_oarchive
oa
(
ofs
);
oa
<<
n
;
ofs
.
close
();
}
NeuronLinear
n2
;
{
std
::
ifstream
ifs
(
"stored_neuron.4n"
);
boost
::
archive
::
text_iarchive
ia
(
ifs
);
ia
>>
n2
;
ifs
.
close
();
}
std
::
cout
<<
n2
.
get_potential
()
<<
" "
<<
n2
.
get_state
()
<<
" "
<<
n2
.
activation_function_get_parameter
(
0
)
<<
" "
<<
n2
.
activation_function_get_parameter
(
1
)
<<
std
::
endl
;
NeuronLinear
n3
(
0.62
,
0.4
);
std
::
cout
<<
n3
.
get_potential
()
<<
" "
<<
n3
.
get_state
()
<<
" "
<<
n3
.
activation_function_get_parameter
(
0
)
<<
" "
<<
n3
.
activation_function_get_parameter
(
1
)
<<
std
::
endl
;
std
::
ofstream
ofs2
(
"stored_neuron2.4n"
);
{
boost
::
archive
::
text_oarchive
oa
(
ofs2
);
oa
<<
n3
;
ofs2
.
close
();
}
NeuronLogistic
n4
;
{
std
::
ifstream
ifs
(
"stored_neuron2.4n"
);
boost
::
archive
::
text_iarchive
ia
(
ifs
);
ia
>>
n4
;
ifs
.
close
();
}
std
::
cout
<<
n4
.
get_potential
()
<<
" "
<<
n4
.
get_state
()
<<
" "
<<
n4
.
activation_function_get_parameter
(
0
)
<<
" "
<<
n4
.
activation_function_get_parameter
(
1
)
<<
std
::
endl
;
NeuronTanh
n5
(
0.5
);
std
::
cout
<<
n5
.
get_potential
()
<<
" "
<<
n5
.
get_state
()
<<
" "
<<
n5
.
activation_function_get_parameter
(
0
)
<<
std
::
endl
;
std
::
ofstream
ofs3
(
"stored_neuron3.4n"
);
{
boost
::
archive
::
text_oarchive
oa
(
ofs3
);
oa
<<
n5
;
ofs3
.
close
();
}
NeuronTanh
n6
;
{
std
::
ifstream
ifs
(
"stored_neuron3.4n"
);
boost
::
archive
::
text_iarchive
ia
(
ifs
);
ia
>>
n6
;
ifs
.
close
();
}
std
::
cout
<<
n6
.
get_potential
()
<<
" "
<<
n6
.
get_state
()
<<
" "
<<
n6
.
activation_function_get_parameter
(
0
)
<<
std
::
endl
;
NeuronBinary
n7
(
0.71
);
std
::
cout
<<
n7
.
get_potential
()
<<
" "
<<
n7
.
get_state
()
<<
" "
<<
n7
.
activation_function_get_parameter
(
0
)
<<
std
::
endl
;
std
::
ofstream
ofs4
(
"stored_neuron4.4n"
);
{
boost
::
archive
::
text_oarchive
oa
(
ofs4
);
oa
<<
n7
;
ofs4
.
close
();
}
NeuronBinary
n8
;
{
std
::
ifstream
ifs
(
"stored_neuron4.4n"
);
boost
::
archive
::
text_iarchive
ia
(
ifs
);
ia
>>
n8
;
ifs
.
close
();
}
std
::
cout
<<
n8
.
get_potential
()
<<
" "
<<
n8
.
get_state
()
<<
" "
<<
n8
.
activation_function_get_parameter
(
0
)
<<
std
::
endl
;
}
/**
* Test of DataSet serialization
*/
...
...
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