Comment by kragen

25 days ago

At least this slice

          h = X
          for i in range(nlayers):
              z = h @ P[2 * i] + P[2 * i + 1]
              # ...
              h = np.maximum(z, 0) if i < nlayers - 1 else z    # ReLU; linear output
              # ...

          logit = h[:, 0]
          # ...

      # ...
      # accuracy of the last forward pass, i.e. before the final update
      return ((logit > 0) == (y > 0.5)).mean()

looks like a perfectly orthodox batch evaluation of a multilayer perceptron, with the input batch in X and weights and biases in P, and that's what it's evaluating the accuracy on. I dumped out P for one of the [8, 64, 1] networks, and it does indeed look like about 650 parameters. I was going to post it here, but printed out as text it's like three pages long, so I won't. I quantized it to one decimal place with [a.round(1) for a in P], and the quantized network still calculates parity perfectly, but it's still a page and a half long.