Skip to content

Commit 3872202

Browse files
authored
Remove Keras HDF5 (#188)
* Exclude HDF5 stuff from README * Add cmake builds to CI * Fix names in CI
1 parent 118f795 commit 3872202

22 files changed

+96
-1158
lines changed

.github/workflows/ci.yml

+28-30
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,50 @@ on:
1414
- "fpm.toml"
1515
- "**.f90"
1616

17-
env:
18-
FPM_FFLAGS: -I/usr/include/hdf5/serial
19-
FPM_LDFLAGS: -L/usr/lib/x86_64-linux-gnu/hdf5/serial
20-
2117
jobs:
2218

23-
build_and_test_debug_profile:
24-
name: Build and test in debug mode
19+
gnu-cmake-debug:
20+
name: gnu-cmake-debug
2521
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Compile
25+
run: cmake -DCMAKE_BUILD_TYPE=Debug -DSERIAL=1 . && make
26+
- name: Test
27+
run: make test
2628

29+
gnu-cmake-release:
30+
name: gnu-cmake-release
31+
runs-on: ubuntu-latest
2732
steps:
33+
- uses: actions/checkout@v4
34+
- name: Compile
35+
run: cmake -DCMAKE_BUILD_TYPE=Release -DSERIAL=1 . && make
36+
- name: Test
37+
run: make test
2838

29-
- uses: fortran-lang/setup-fpm@v4
39+
gnu-fpm-debug:
40+
name: gnu-fpm-debug
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: fortran-lang/setup-fpm@v5
3044
with:
31-
fpm-version: "v0.6.0"
32-
33-
- name: Install HDF5
34-
run: |
35-
sudo apt update
36-
sudo apt install --no-install-recommends libhdf5-dev
37-
- uses: actions/checkout@v2
38-
45+
fpm-version: "v0.10.1"
46+
- uses: actions/checkout@v4
3947
- name: Compile
4048
run: fpm build --profile debug
41-
4249
- name: Test
4350
run: fpm test --profile debug
4451

45-
build_and_test_release_profile:
46-
name: Build and test in release mode
52+
gnu-fpm-release:
53+
name: gnu-fpm-release
4754
runs-on: ubuntu-latest
48-
4955
steps:
50-
51-
- uses: fortran-lang/setup-fpm@v4
56+
- uses: fortran-lang/setup-fpm@v5
5257
with:
53-
fpm-version: "v0.6.0"
54-
55-
- name: Install HDF5
56-
run: |
57-
sudo apt update
58-
sudo apt install --no-install-recommends libhdf5-dev
59-
- uses: actions/checkout@v2
60-
58+
fpm-version: "v0.10.1"
59+
- uses: actions/checkout@v4
6160
- name: Compile
6261
run: fpm build --profile release
63-
6462
- name: Test
6563
run: fpm test --profile release

CMakeLists.txt

+2-19
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@ if(NOT CMAKE_BUILD_TYPE)
66
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build Release")
77
endif()
88

9-
project(neural-fortran
10-
LANGUAGES C Fortran
11-
)
9+
project(neural-fortran LANGUAGES Fortran)
1210

1311
enable_testing()
1412

15-
include(FetchContent)
16-
1713
include(cmake/options.cmake)
1814
include(cmake/compilers.cmake)
1915

20-
include(cmake/functional.cmake)
21-
include(cmake/h5fortran.cmake)
22-
include(cmake/json.cmake)
23-
2416
# library to archive (libneural-fortran.a)
2517
add_library(neural-fortran
2618
src/nf.f90
@@ -40,8 +32,6 @@ add_library(neural-fortran
4032
src/nf/nf_input1d_layer_submodule.f90
4133
src/nf/nf_input3d_layer.f90
4234
src/nf/nf_input3d_layer_submodule.f90
43-
src/nf/nf_keras.f90
44-
src/nf/nf_keras_submodule.f90
4535
src/nf/nf_layer_constructors.f90
4636
src/nf/nf_layer_constructors_submodule.f90
4737
src/nf/nf_layer.f90
@@ -61,16 +51,9 @@ add_library(neural-fortran
6151
src/nf/nf_reshape_layer_submodule.f90
6252
src/nf/io/nf_io_binary.f90
6353
src/nf/io/nf_io_binary_submodule.f90
64-
src/nf/io/nf_io_hdf5.f90
65-
src/nf/io/nf_io_hdf5_submodule.f90
6654
)
6755

68-
target_link_libraries(neural-fortran PRIVATE
69-
functional::functional
70-
h5fortran::h5fortran
71-
HDF5::HDF5
72-
jsonfortran::jsonfortran
73-
)
56+
target_link_libraries(neural-fortran PRIVATE)
7457

7558
install(TARGETS neural-fortran)
7659

README.md

+10-40
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ Read the paper [here](https://arxiv.org/abs/1902.06714).
2121
RMSProp, Adagrad, Adam, AdamW
2222
* More than a dozen activation functions and their derivatives
2323
* Loss functions and metrics: Quadratic, Mean Squared Error, Pearson Correlation etc.
24-
* Loading dense and convolutional models from Keras HDF5 (.h5) files
2524
* Data-based parallelism
25+
* Loading dense and convolutional models from Keras HDF5 (.h5) files
26+
(see the [nf-keras-hdf5](https://github.com/neural-fortran/nf-keras-hdf5) add-on)
2627

2728
### Available layers
2829

@@ -51,14 +52,8 @@ cd neural-fortran
5152
Required dependencies are:
5253

5354
* A Fortran compiler
54-
* [HDF5](https://www.hdfgroup.org/downloads/hdf5/)
55-
(must be provided by the OS package manager or your own build from source)
56-
* [functional-fortran](https://github.com/wavebitscientific/functional-fortran),
57-
[h5fortran](https://github.com/geospace-code/h5fortran),
58-
[json-fortran](https://github.com/jacobwilliams/json-fortran)
59-
(all handled by neural-fortran's build systems, no need for a manual install)
6055
* [fpm](https://github.com/fortran-lang/fpm) or
61-
[CMake](https://cmake.org) for building the code
56+
[CMake](https://cmake.org) to build the code
6257

6358
Optional dependencies are:
6459

@@ -79,23 +74,7 @@ Compilers tested include:
7974
With gfortran, the following will create an optimized build of neural-fortran:
8075

8176
```
82-
fpm build \
83-
--profile release \
84-
--flag "-I$HDF5INC -L$HDF5LIB"
85-
```
86-
87-
HDF5 is now a required dependency, so you have to provide it to fpm.
88-
The above command assumes that the `HDF5INC` and `HDF5LIB` environment
89-
variables are set to the include and library paths, respectively, of your
90-
HDF5 install.
91-
92-
If you use Conda, the following instructions work:
93-
94-
```
95-
conda create -n nf hdf5
96-
conda activate nf
97-
fpm build --profile release --flag "-I$CONDA_PREFIX/include -L$CONDA_PREFIX/lib -Wl,-rpath -Wl,$CONDA_PREFIX/lib"
98-
fpm test --profile release --flag "-I$CONDA_PREFIX/include -L$CONDA_PREFIX/lib -Wl,-rpath -Wl,$CONDA_PREFIX/lib"
77+
fpm build --profile release
9978
```
10079

10180
#### Building in parallel mode
@@ -106,25 +85,20 @@ Once installed, use the compiler wrappers `caf` and `cafrun` to build and execut
10685
in parallel, respectively:
10786

10887
```
109-
fpm build \
110-
--compiler caf \
111-
--profile release \
112-
--flag "-I$HDF5INC -L$HDF5LIB"
88+
fpm build --compiler caf --profile release
11389
```
11490

11591
#### Testing with fpm
11692

11793
```
118-
fpm test \
119-
--profile release \
120-
--flag "-I$HDF5INC -L$HDF5LIB"
94+
fpm test --profile release
12195
```
12296

12397
For the time being, you need to specify the same compiler flags to `fpm test`
12498
as you did in `fpm build` so that fpm knows it should use the same build
12599
profile.
126100

127-
See [Fortran Package Manager](https://github.com/fortran-lang/fpm) for more info on fpm.
101+
See the [Fortran Package Manager](https://github.com/fortran-lang/fpm) for more info on fpm.
128102

129103
### Building with CMake
130104

@@ -156,8 +130,7 @@ cafrun -n 4 bin/mnist # run MNIST example on 4 cores
156130
#### Building with a different compiler
157131

158132
If you want to build with a different compiler, such as Intel Fortran,
159-
set the `HDF5_ROOT` environment variable to the root path of your
160-
Intel HDF5 build, and specify `FC` when issuing `cmake`:
133+
specify `FC` when issuing `cmake`:
161134

162135
```
163136
FC=ifort cmake ..
@@ -213,6 +186,7 @@ You can configure neural-fortran by setting the appropriate options before
213186
including the subproject.
214187

215188
The following should be added in the CMake file of your directory:
189+
216190
```cmake
217191
if(NOT TARGET "neural-fortran::neural-fortran")
218192
find_package("neural-fortran" REQUIRED)
@@ -230,11 +204,7 @@ examples, in increasing level of complexity:
230204
3. [dense_mnist](example/dense_mnist.f90): Hand-written digit recognition
231205
(MNIST dataset) using a dense (fully-connected) network
232206
4. [cnn_mnist](example/cnn_mnist.f90): Training a CNN on the MNIST dataset
233-
5. [dense_from_keras](example/dense_from_keras.f90): Creating a pre-trained
234-
dense model from a Keras HDF5 file and running the inference.
235-
6. [cnn_from_keras](example/cnn_from_keras.f90): Creating a pre-trained
236-
convolutional model from a Keras HDF5 file and running the inference.
237-
7. [get_set_network_params](example/get_set_network_params.f90): Getting and
207+
5. [get_set_network_params](example/get_set_network_params.f90): Getting and
238208
setting hyperparameters of a network.
239209

240210
The examples also show you the extent of the public API that's meant to be

cmake/functional.cmake

-18
This file was deleted.

cmake/h5fortran.cmake

-15
This file was deleted.

cmake/json.cmake

-35
This file was deleted.

example/CMakeLists.txt

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
foreach(execid
22
cnn_mnist
3-
cnn_from_keras
43
dense_mnist
5-
dense_from_keras
64
get_set_network_params
75
network_parameters
86
simple
@@ -12,8 +10,6 @@ foreach(execid
1210
add_executable(${execid} ${execid}.f90)
1311
target_link_libraries(${execid} PRIVATE
1412
neural-fortran
15-
h5fortran::h5fortran
16-
jsonfortran::jsonfortran
1713
${LIBS}
1814
)
1915
endforeach()

example/cnn_from_keras.f90

-58
This file was deleted.

0 commit comments

Comments
 (0)