38 votes

Machine Learning Golf: Multiplication

21 13 11 9 weights This is based on the polarization identity of bilinear forms which in the one dimensional real case reduces to the polynomial identity: $$ x\cdot y = \frac{(x+y)^2 - (x-y)^2}{4}$$ ...
flawr's user avatar
  • 43.8k
32 votes

Machine Learning Golf: Multiplication

7 weights ...
xnor's user avatar
  • 145k
22 votes

Machine Learning Golf: Multiplication

33 31 weights ...
Grimmy's user avatar
  • 15.7k
15 votes

Machine Learning Golf: Multiplication

43 weights The two solutions posted so far have been very clever but their approaches likely won't work for more traditional tasks in machine learning (like OCR). Hence I'd like to submit a 'generic' ...
Stefan Mesken's user avatar
14 votes

Can a neural network recognize primes?

Trial division: score 59407, 6243 layers, 16478 neurons in total Given as a Python program which generates and validates the net. See the comments in trial_division...
Peter Taylor's user avatar
  • 43.1k
14 votes

Sort with a neural network

Octave, 96 88 87 84 76 54 50 weights & biases This 6-layer neural net is essentially a 3-step sorting network built from a very simple min/...
flawr's user avatar
  • 43.8k
9 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Python 3, 101 108 bytes def f(m,w):r=range(0,len(m),w);return[[max(sum([x[i:i+w]for x in m[j:j+w]],[]))for i in r]for j in r] Thanks to Jo King and Jonathan ...
JPeroutek's user avatar
  • 822
9 votes

Machine Learning Golf: Multiplication

2 weights I was inspired by the other answers to approximate the polarization identity in a different way. For every small \$\epsilon>0\$, it holds that $$ xy \approx \frac{e^{\epsilon x+\epsilon ...
Dustin G. Mixon's user avatar
8 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Jelly, 6 bytes »⁹/Z$⁺ A dyadic Link accepting the matrix (list of lists) on the left and the window size on the right which yields a matrix (list of lists). Try it ...
Jonathan Allan's user avatar
7 votes

Can a neural network recognize primes?

Score 984314, 82027 layers, 246076 neurons in total We can keep things entirely in the integers if we use activation function ReLU, which simplifies the analysis. Given an input \$x\$ which is known ...
Peter Taylor's user avatar
  • 43.1k
7 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

J, 15 14 bytes -1 byte, thanks @Bubbler The left argument is the matrix and the right argument is the stride. >./@,;.3~2 2&$ Try it online!
Traws's user avatar
  • 921
7 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Octave with Image Package, 38 bytes @(M,s)blockproc(M,[s s],@(b)max(b(:))) Try it online!
Luis Mendo's user avatar
  • 104k
6 votes

Find the largest root of a polynomial with a neural network

14,674,000,667 5,436,050 5,403,448 10,385 5,994 4,447 3,806 total precision For a baseline, I investigated the following approach: Select \$M,\delta,\epsilon>0\$ such that if we sample the ...
Dustin G. Mixon's user avatar
6 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

J, 13 12 bytes >./\&|:^:2~- Try it online! ... When I said ";.3 is the right tool for the job", I was wrong. This ...
Bubbler's user avatar
  • 76k
5 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

APL (Dyalog Unicode), 20 bytes {⌈⌿⍤2⌈/⍵}⊢⍴⍨4⍴÷⍨∘≢,⊣ Try it online! I'm pretty sure converting the dfn part into an atop ...
Bubbler's user avatar
  • 76k
5 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Python 2, 68 bytes lambda M,k:eval("map(lambda*l:map(max,zip(*[iter(l)]*k)),*"*2+"M))") Try it online! 74 bytes ...
xnor's user avatar
  • 145k
5 votes

Is this stack of CNN layers valid?

Python 3.8 (pre-release), 138 134 118 bytes ...
fireflame241's user avatar
  • 16.3k
3 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Wolfram Language (Mathematica), 23 bytes BlockMap[Max,#2,{#,#}]& Try it online!
Lukas Lang's user avatar
3 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

dzaima/APL, 14 12 bytes ⊣t¨t←⌈/⍬∘⍮⍛⍴ Try it online!
dzaima's user avatar
  • 20.2k
3 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

05AB1E, 8 7 bytes ôεø¹ôεZ -1 byte thanks to @Grimy. Stride as first input and matrix as second input. Try it online or verify all test cases. Explanation: ...
Kevin Cruijssen's user avatar
3 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

J, 23 bytes (#@];~@$1{.~[)>./@,;.1] Try it online!
Galen Ivanov's user avatar
2 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

JavaScript (ES6), 85 bytes Takes input as (s)(matrix). ...
Arnauld's user avatar
  • 192k
2 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Python 3, 275 196 184 163 159 111 bytes def f(s,m):r=range(len(m)//s);return[[max(b for k in range(s)for b in m[i*s+k][j*s:][:s])for j in r]for i in r] Try it ...
Paul-B98's user avatar
  • 583
2 votes

Find the largest root of a polynomial with a neural network

53,268 29,596 29,306 total precision Private communication with @A.Rex led to this solution, in which we construct a neural net that memorizes the answers. The core idea is that every function \$f\...
Dustin G. Mixon's user avatar
2 votes

Is this stack of CNN layers valid?

J, 84 bytes Takes in a list of layers; mode x y for convolution, with _1 0 1 for min mid max,...
xash's user avatar
  • 11.3k
2 votes

Is this stack of CNN layers valid?

05AB1E, 45 bytes sεÐgiĀ«]vyн³Dp-Nè©*-yθ/®+ÐïÊyнÈ®_*y`‹«à~i0q]1 Inspired by @fireflame241's ungolfed Python answer, so make sure to upvote him! Three loose inputs: ...
Kevin Cruijssen's user avatar
2 votes

Implement the Max-Pooling operation from Convolutional Neural Networks

Charcoal, 24 bytes NθIE⪪EAE⪪ιθ⌈λθE§ι⁰⌈Eι§νμ Try it online! Link is to verbose version of code. Outputs each maximum on its own line, with matrix rows double-...
Neil's user avatar
  • 170k
1 vote

Implement the Max-Pooling operation from Convolutional Neural Networks

Japt, 24 bytes mòY=UÊzV)Õc òYp)®rwÃòV y Try it ...
AZTECCO's user avatar
  • 10.8k
1 vote

Implement the Max-Pooling operation from Convolutional Neural Networks

Ruby, 57 bytes ->m,w{g=->r{r.transpose.each_slice(w).map &:max};g[g[m]]} Try it online!
G B's user avatar
  • 21.9k
1 vote

Implement the Max-Pooling operation from Convolutional Neural Networks

Stax, 11 bytes ó╚←XF«≡ûÖçx Run and debug it at staxlang.xyz! Unpacked (13 bytes) and explanation ...
Khuldraeseth na'Barya's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible