modern-fortran / neural-fortran

A parallel framework for deep learning
MIT License
398 stars 82 forks source link

fpm test produces runtime error due to missing file #35

Closed rouson closed 2 years ago

rouson commented 2 years ago
 % fpm test --compiler caf --flag "-cpp -DCAF -O3 -ffast-math"
 T T T T T T T T T T T T T T T T T T T T
 All tests passed.
 Initializing 2 networks with random weights and biases
 Save network 1 into file
 Load network 2 from file
 Layer            1 , weights equal:  T , biases equal: T
 Layer            2 , weights equal:  T , biases equal: T
 Layer            3 , weights equal:  T , biases equal: T

 Setting different activation functions for each layer of network 1
 Save network 1 into file
 Load network 2 from file
 Layer            1 , activation functions equal: T (network 1: sigmoid, network 2: sigmoid)
 Layer            2 , activation functions equal: T (network 1: tanh, network 2: tanh)
 Layer            3 , activation functions equal: T (network 1: gaussian, network 2: gaussian)
 Reading MNIST data..
At line 36 of file ././src/mod_io.f90
Fortran runtime error: Cannot open file '../data/mnist/mnist_training_images.dat': No such file or directory

Error termination. Backtrace:
#0  0x1090486ee
#1  0x109049395
#2  0x109049f7b
#3  0x109267638
#4  0x10926791c
#5  0x108320931
#6  0x108320ff2
#7  0x10831f29a
#8  0x1083317fb
           1 -0.152883232       2.73143500E-02  0.131976783     -0.170446441     -0.293200493       3.38315852E-02  0.328212768     -0.113486469     -0.259437263     -0.248188660      0.214462832      0.278976798      -5.90201877E-02 -0.289550871     -0.366032451    
<ERROR> Execution failed for object " test_mnist "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1
milancurcic commented 2 years ago

Thanks! This is due to the relative path being hardcoded in src/mod_io.f90, which assumes that the tests are run from build/, which was true for the CMake build but doesn't work for fpm. In the short-term, you can either:

  1. Move the data/ directory so that the relative path works from where you're executing fpm test; or
  2. Change the hardcoded path in src/mod_io.f90 so that the relative path works from where you're executing fpm test.

In the long-term, a solution could be to allow specifying a path to the data as an actual argument to load_mnist, with the default being some common place where nf data will be placed, like what TensorFlow+Keras does.

Any ideas and suggestions are welcome, of course.

I received a small grant from NASA to implement CNNs and HDF5 I/O in nf and plan to address the data path issues as part of that effort.

rouson commented 2 years ago

@milancurcic any of the above approaches is fine to me. If you have a preference, I'll submit a pull request with the change.