-
Notifications
You must be signed in to change notification settings - Fork 92
Refactor: move procedure definitions submodules #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a3530af
refac(mod_random): mv procedure defs to submodule
rouson e722771
refac(mod_parallel): mv procedure def to submodule
rouson b1c8f38
refac(mod_io): mv procedure defs to submodule
rouson 153a54c
refac(mod_mnist): mv procedure defs to submodule
rouson 8683473
refac(mod_activation): mv proc defs to submodule
rouson ae39c21
refac(mod_layer): mv procedure defs to submodule
rouson ebc5de7
refac(mod_network): mv procedure defs to submodule
rouson 2e81268
fix(mod_network_subm): add module keyword bef subr
rouson 4164981
Fix indentation
milancurcic 3f59a28
Add submodule files to the library for CMake builds
milancurcic ed3d802
fix(network/layer): ifort func result workaround
rouson 31fe4fb
Add note about required compiler versions
milancurcic a51dd2a
Bump version
milancurcic bc13121
Fix version number; tag from main will still be 0.1.0
milancurcic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name = "neural-fortran" | ||
version = "0.1.0" | ||
version = "0.2.0" | ||
license = "MIT" | ||
author = "Milan Curcic" | ||
maintainer = "[email protected]" | ||
copyright = "Copyright 2018-2021, neural-fortran contributors" | ||
copyright = "Copyright 2018-2022, neural-fortran contributors" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
submodule(mod_activation) mod_activation_submodule | ||
|
||
!! A collection of activation functions and their derivatives. | ||
|
||
implicit none | ||
|
||
contains | ||
|
||
pure module function gaussian(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = exp(-x**2) | ||
end function gaussian | ||
|
||
pure module function gaussian_prime(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = -2 * x * gaussian(x) | ||
end function gaussian_prime | ||
|
||
pure module function relu(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = max(0., x) | ||
end function relu | ||
|
||
pure module function relu_prime(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
where (x > 0) | ||
res = 1 | ||
elsewhere | ||
res = 0 | ||
end where | ||
end function relu_prime | ||
|
||
pure module function sigmoid(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = 1 / (1 + exp(-x)) | ||
endfunction sigmoid | ||
|
||
pure module function sigmoid_prime(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = sigmoid(x) * (1 - sigmoid(x)) | ||
end function sigmoid_prime | ||
|
||
pure module function step(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
where (x > 0) | ||
res = 1 | ||
elsewhere | ||
res = 0 | ||
end where | ||
end function step | ||
|
||
pure module function step_prime(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = 0 | ||
end function step_prime | ||
|
||
pure module function tanhf(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = tanh(x) | ||
end function tanhf | ||
|
||
pure module function tanh_prime(x) result(res) | ||
real(rk), intent(in) :: x(:) | ||
real(rk) :: res(size(x)) | ||
res = 1 - tanh(x)**2 | ||
end function tanh_prime | ||
|
||
end submodule mod_activation_submodule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
submodule(mod_io) mod_io_submodule | ||
|
||
implicit none | ||
|
||
contains | ||
|
||
module subroutine read_binary_file_1d(filename, dtype, nrec, array) | ||
character(len=*), intent(in) :: filename | ||
integer(ik), intent(in) :: dtype, nrec | ||
real(rk), allocatable, intent(in out) :: array(:) | ||
integer(ik) :: fileunit | ||
allocate(array(nrec)) | ||
open(newunit=fileunit, file=filename, access='direct',& | ||
action='read', recl=dtype * nrec, status='old') | ||
read(fileunit, rec=1) array | ||
close(fileunit) | ||
end subroutine read_binary_file_1d | ||
|
||
module subroutine read_binary_file_2d(filename, dtype, dsize, nrec, array) | ||
character(len=*), intent(in) :: filename | ||
integer(ik), intent(in) :: dtype, dsize, nrec | ||
real(rk), allocatable, intent(in out) :: array(:,:) | ||
integer(ik) :: fileunit, i | ||
allocate(array(dsize, nrec)) | ||
open(newunit=fileunit, file=filename, access='direct',& | ||
action='read', recl=dtype * dsize, status='old') | ||
do i = 1, nrec | ||
read(fileunit, rec=i) array(:,i) | ||
end do | ||
close(fileunit) | ||
end subroutine read_binary_file_2d | ||
|
||
end submodule mod_io_submodule |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.