Skip to content

Instantly share code, notes, and snippets.

View Beliavsky's full-sized avatar

Beliavsky

View GitHub Profile
@stfwn
stfwn / nn.py
Last active December 21, 2020 04:32
A Neural Network in Python From Start to Finish
import numpy as np
import matplotlib.pyplot as plt
from urllib import request
import gzip
import pickle
import os
"""Load up the data.
This is not that interesting. Let's just copy paste it from https://github.com/hsjeong5/MNIST-for-Numpy."""

Two schools

There are two schools how to write numerical code, which in this document we will call the IEEE school and the Fortran school.

One end of the spectrum: no changes in floating point by the compiler, the developer must express exact intent. This is the IEEE school.

On the other end of the spectrum: Developer specifies math, the compiler is

@mp4096
mp4096 / fortran-notes.md
Last active February 24, 2022 02:10
Notes on Fortran

Notes on Fortran

These are some initial impressions of Fortran 2008 as seen by a MATLAB person.

Very generally, I would say Fortran is quite similar to MATLAB (I know that it's actually the other way round). Apart from this, here are some language features that I found quite interesting/quirky/nice/annoying (in no particular order):

  • Implicit typing:
    • Implicit typing in Fortran has nothing to do with modern type inference (a-la auto in C++11)! If it is active, the compiler tries to assign types based on variable names. 😱 So it is really necessary to always use implicit none.
  • Array indexing:
    • Can be specified by the programmer, e.g. one can start indexing with 0 or even use negative indices. On the other hand: Prepare to memorise scenarios in which indices are remapped to 1:N by default and a couple of cases when indices remain the same.
    • MATLAB slices are specified as <lower bound> : <step size> : <upper bound>, whereas Fortran uses ` :