Fortran Misconceptions

For several months, I’ve been developing a close-source (sorry :crazy_face:) artificial intelligence project written from scratch in pure Fortran, which I want to use for business purposes (hopefully, my business plan will work but this whole project is a crazy experiment I’ve dedicated months of my life with no guarantee of success yet :grin:).

In essence, it’s a neural network with some recurrent elements analyzing large sets of numbers. Months ago I started the development in Rust, the programming language I feel most comfortable with :sparkling_heart:. But early I ran into performance issues running the neural network on my laptop. Experimentally, I had rewritten the neural network in Fortran (ChatGPT sped up the translation of some code pieces despite lots of mistakes) and I found the Fortran implementation to be several times more performant than the Rust code (especially, when compiled with the -Ofast -march=native flags).

Possibly, there exists some way to optimize the Rust code or compilation process I have not fully explored. But there’s still another reason why I’ll stick with Fortran. While writing a “classical” algorithm if else then I’d rather employ a language like Rust, which is very well-structured. I feel that the development of my neural network was in many regards different from writing a classical program, because rather than on planning, it was based on experimentation, on testing of hundreds of (almost random) neural network architectures and settings seeking for the one which some miraculous way (I don’t fully understand) gives the right output. I’d describe it as a natural evolution via thousands of experiments failing to work 99.9% of the time rather than as an intelligent design of a classical algorithm.

So, rather than a nicely-structured code (like that in Rust), what I needed was an easily-edited code (like that in Fortran). Folks, if you want to do artificial intelligence think of (1) performance and (2) editability of your code. Fortran offers a solution which is both highly-performant and well-editable. It is perfect for AI. :hugs:

16 Likes