Skip to content

Commit 9e269ba

Browse files
authored
Merge pull request #37 from modern-fortran/35-fix-mnist-relative-path
Fix MNIST relative path and add instructions for running tests
2 parents 657b477 + fe134a9 commit 9e269ba

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ in parallel, respectively:
6161
fpm build --compiler caf --flag "-cpp -DCAF -O3 -ffast-math"
6262
```
6363

64+
#### Testing with fpm
65+
66+
```
67+
fpm test --flag "-cpp -O3 -ffast-math -fcoarray=single"
68+
```
69+
70+
For the time being, you need to specify the same compiler flags to `fpm test`
71+
as you did in `fpm build` so that fpm can figure out to use the same build
72+
profile.
73+
6474
See [Fortran Package Manager](https://github.com/fortran-lang/fpm) for more info on fpm.
6575

6676
### Building with CMake
@@ -136,6 +146,25 @@ To build with debugging flags enabled, type:
136146
cmake .. -DCMAKE_BUILD_TYPE=debug
137147
```
138148

149+
#### Running tests with CMake
150+
151+
Before running the tests, link the the data/ directory to the current directory:
152+
153+
```
154+
ln -s ../data
155+
```
156+
157+
The MNIST dataset which comes with the code as a tarball must be unpacked first.
158+
See [MNIST training example](#mnist-training-example) on how to do that.
159+
Once the MNIST dataset is unpacked and the data/ directory is linked in your
160+
CMake build/ directory, run
161+
162+
```
163+
ctest
164+
```
165+
166+
to run the tests.
167+
139168
## Examples
140169

141170
### Creating a network

src/mod_mnist.f90

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,20 @@ subroutine load_mnist(tr_images, tr_labels, te_images,&
4949
integer(ik), parameter :: te_nimages = 10000
5050
integer(ik), parameter :: va_nimages = 10000
5151

52-
call read_binary_file('../data/mnist/mnist_training_images.dat',&
52+
call read_binary_file('data/mnist/mnist_training_images.dat',&
5353
dtype, image_size, tr_nimages, tr_images)
54-
call read_binary_file('../data/mnist/mnist_training_labels.dat',&
54+
call read_binary_file('data/mnist/mnist_training_labels.dat',&
5555
dtype, tr_nimages, tr_labels)
5656

57-
call read_binary_file('../data/mnist/mnist_testing_images.dat',&
57+
call read_binary_file('data/mnist/mnist_testing_images.dat',&
5858
dtype, image_size, te_nimages, te_images)
59-
call read_binary_file('../data/mnist/mnist_testing_labels.dat',&
59+
call read_binary_file('data/mnist/mnist_testing_labels.dat',&
6060
dtype, te_nimages, te_labels)
6161

6262
if (present(va_images) .and. present(va_labels)) then
63-
call read_binary_file('../data/mnist/mnist_validation_images.dat',&
63+
call read_binary_file('data/mnist/mnist_validation_images.dat',&
6464
dtype, image_size, va_nimages, va_images)
65-
call read_binary_file('../data/mnist/mnist_validation_labels.dat',&
65+
call read_binary_file('data/mnist/mnist_validation_labels.dat',&
6666
dtype, va_nimages, va_labels)
6767
end if
6868

0 commit comments

Comments
 (0)