modern-fortran / neural-fortran

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

getting / setting network parameters (third-time lucky with tab space formatting) #107

Closed jvo203 closed 1 year ago

jvo203 commented 1 year ago

Regarding the indenting, in the macOS vscode I have already been using the "Modern Fortran" extension as recommended by you. The "fprettify" vscode extension is not installed. Searching the installed extensions for "fortran" only returns "Modern Fortran", no other stuff is installed. In the vscode I have just set "Editor: Tab Size" to 2 and disabled automatic tab size recognition from existing files. Then I touched and saved all the modified .f90 files, triggering automatic re-formatting upon save with the tab size set to 2. Hopefully the files now look more like what you expect them to be.

Please let me know if there are any more settings that might need changing in vscode. If this PR does not fix indenting then it might have to be "over to you" upon your return to work. No worries, this stuff can wait!

jvo203 commented 1 year ago

An improvement: in the top file nf_network_submodule.f90, the subroutine get_parameters(self, params), it makes sense to add

if (allocated(params)) deallocate(params)

right before the loop

do n = 1, size(self%layers)

Some users might repeatedly call get_parameters (for whatever reason), the fix makes sure the params array is emptied / deallocated prior to any 2nd-time use. Otherwise parameters would keep getting appended to the end of the existing params array instead of being written starting at the beginning of params.