Skip to content

Instantly share code, notes, and snippets.

@harpone
Created September 8, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harpone/c5fe6241960f8a84d0d91f919b62be04 to your computer and use it in GitHub Desktop.
Save harpone/c5fe6241960f8a84d0d91f919b62be04 to your computer and use it in GitHub Desktop.
Serial 1 layer NN
# SERIAL:
W = parameter(M, N)
def forward(x_: float32[N]) -> float32:
# matrix-vector multiplication:
zs = float32[M] # let's imagine we have a float32 dtype in Vyper
for i, W_row in enumerate(W):
zs[i] = dot(W_row, x_) # 'dot' is an external smart contract
# summation:
y = sum(zs) # scalar
return y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment