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
4afb3d71
Commit
4afb3d71
authored
6 years ago
by
Martin Beseda
Browse files
Options
Downloads
Patches
Plain Diff
NEW: Added files net_m_mem_leak_test.out and net_m.f90.
parent
0179c377
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/net_m.f90
+170
-0
170 additions, 0 deletions
src/net_m.f90
src/net_m_mem_leak_test.f90
+24
-0
24 additions, 0 deletions
src/net_m_mem_leak_test.f90
src/neuron_m.f90
+1
-1
1 addition, 1 deletion
src/neuron_m.f90
with
195 additions
and
1 deletion
src/net_m.f90
0 → 100644
+
170
−
0
View file @
4afb3d71
!> Module containing classes representing the whole
!! neural network.
!!
!! It uses 'neuron_m' module.
!!
!! @author Martin Beseda
!! @date 2018
module
net_m
!use interconnection_m
use
data_kinds_4neuro_m
use
time_measurement_m
use
neuron_m
use
connection_m
implicit
none
public
!-------------!------------------------------------------------------------------------------
! class net_t !
!-------------!
!> Class representing a general network
type
::
net_t
private
character
(:),
allocatable
::
net_type
!< Type of the net
integer
(
kind
=
integer_4neuro
)
::
num_of_neurons
!< Number of neurons in the net
character
(:),
allocatable
::
training_method
!< Used training method
class
(
neuron_t
),
allocatable
::
neuron_arr
!< Array containing all neurons
integer
(
kind
=
integer_4neuro
),
allocatable
::
input_neuron_arr
!< Array of input neuron indices
integer
(
kind
=
integer_4neuro
),
allocatable
::
output_neuron_arr
!< Array of output neuron indices
class
(
connection_t
),
allocatable
::
connection_arr
!< Array of all connections
contains
!> Prints information about the network to the standard output.
procedure
::
print_info
=>
print_info_impl
!> Saves the network instance to the Fortran binary file
procedure
::
save_net_bin
=>
save_net_bin_impl
end
type
net_t
interface
net_t
!> Constructor of net_t class
!! Loads complete info about network from file
!! @oaram[in] filepath Path to the file with network configuration
!! @return Returns pointer to the new instance of the class net_t
module
procedure
::
new_net_1
end
interface
net_t
!------------------!---------------------------------------------------------------------
! class mock_net_t !
!------------------!
!> Mock net_t class
type
,
extends
(
net_t
)
::
mock_net_t
end
type
mock_net_t
interface
mock_net_t
!> Non-parametric constructor of mock_net_t class
!! @return Returns pointer to the instance of the class mock_net_t
module
procedure
::
new_mock_net
end
interface
mock_net_t
contains
!------------------------!---------------------------------------------------------------
! Method implementations !
!------------------------!
!-------------!--------------------------------------------------------------------------
! class net_t !
!-------------!
!--------------!-------------------------------------------------------------------------
! Constructors !
!--------------!
!> Constructor of net_t class
!! Loads complete info about network from Fortran binary file
!! @oaram[in] filepath Path to the JSON file with network configuration
!! @return Returns pointer to the instance of the class net_t
function
new_net_1
(
filepath
)
result
(
new_obj
)
character
(
len
=*
),
intent
(
in
)
::
filepath
class
(
net_t
),
pointer
::
new_obj
character
(
len
=
50
)
::
str
!TODO udelat dynamicky, ne s fixni delkou
#ifdef TIME_PROFILING
real
::
start_time
call
time_profiling_start
(
start_time
)
#endif
allocate
(
new_obj
)
open
(
unit
=
11
,
file
=
filepath
,
form
=
"unformatted"
,
status
=
"old"
)
read
(
11
)
str
read
(
11
)
new_obj
%
num_of_neurons
print
*
,
str
new_obj
%
net_type
=
str
!TODO dopsat
#ifdef TIME_PROFILING
call
time_profiling_stop
(
start_time
,
'new_net'
)
#endif
end
function
new_net_1
!> Prints information about the network to the standard output.
subroutine
print_info_impl
(
this
)
class
(
net_t
),
intent
(
in
)
::
this
#ifdef TIME_PROFILING
real
::
start_time
call
time_profiling_start
(
start_time
)
#endif
write
(
*
,
*
)
'+--------------+'
write
(
*
,
*
)
'| Network info |'
write
(
*
,
*
)
'+--------------|'
write
(
*
,
*
)
'Type: '
,
this
%
net_type
write
(
*
,
*
)
'Number of neurons: '
,
this
%
num_of_neurons
!TODO dopsat
#ifdef TIME_PROFILING
call
time_profiling_stop
(
start_time
,
'print_info_impl'
)
#endif
end
subroutine
print_info_impl
!----------------!-----------------------------------------------------------------------
! Common methods !
!----------------!
!> Saves the network instance to the Fortran binary file
subroutine
save_net_bin_impl
(
this
,
filename
)
class
(
net_t
),
intent
(
in
)
::
this
!< Instance of the class 'net_t'
character
(
len
=*
),
intent
(
in
)
::
filename
!< Name of the file, where the net will be saved into
open
(
unit
=
11
,
file
=
filename
,
form
=
"unformatted"
)
write
(
11
)
this
%
net_type
write
(
11
)
this
%
num_of_neurons
close
(
unit
=
11
)
end
subroutine
save_net_bin_impl
!------------------!---------------------------------------------------------------------
! class mock_net_t !
!------------------!
!--------------!-------------------------------------------------------------------------
! Constructors !
!--------------!
!> Contructor of mock_net_t class
!! @return Returns pointer to the instance of the class mock_net_t
function
new_mock_net
()
result
(
new_obj
)
class
(
net_t
),
pointer
::
new_obj
#ifdef TIME_PROFILING
real
::
start_time
call
time_profiling_start
(
start_time
)
#endif
allocate
(
new_obj
)
new_obj
%
net_type
=
'MOCK NETWORK'
new_obj
%
num_of_neurons
=
5
new_obj
%
training_method
=
'MOCK TRAINING'
!TODO dopsat init zbylych polozek
#ifdef TIME_PROFILING
call
time_profiling_stop
(
start_time
,
'new_mock_net'
)
#endif
end
function
new_mock_net
end
module
net_m
This diff is collapsed.
Click to expand it.
src/net_m_mem_leak_test.f90
0 → 100644
+
24
−
0
View file @
4afb3d71
program
net_mem_leak_test
use
data_kinds_4neuro_m
use
net_m
class
(
net_t
),
pointer
::
net1
,
net2
print
*
,
'+--------------------------------------------------+'
print
*
,
'| STARTING MEMORY LEAK TESTING OF THE MODULE NET_M |'
print
*
,
'+--------------------------------------------------+'
print
*
,
'Creating instances of the class net_t...'
net1
=>
mock_net_t
()
call
net1
%
print_info
()
call
net1
%
save_net_bin
(
"stored_net.dat"
)
net2
=>
net_t
(
"stored_net.dat"
)
call
net2
%
print_info
()
deallocate
(
net1
)
deallocate
(
net2
)
end
program
net_mem_leak_test
This diff is collapsed.
Click to expand it.
src/neuron_m.f90
+
1
−
1
View file @
4afb3d71
...
@@ -287,7 +287,7 @@ module neuron_m
...
@@ -287,7 +287,7 @@ module neuron_m
call
time_profiling_start
(
start_time
)
call
time_profiling_start
(
start_time
)
#endif
#endif
this
%
potential
=
0
this
%
potential
=
0
this
%
state
=
0
this
%
state
=
0
!TODO maybe init with values from normal distribution
#ifdef TIME_PROFILING
#ifdef TIME_PROFILING
call
time_profiling_stop
(
start_time
,
'neuron_init_components_impl'
)
call
time_profiling_stop
(
start_time
,
'neuron_init_components_impl'
)
...
...
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