Skip to content

Instantly share code, notes, and snippets.

View naitoh's full-sized avatar

NAITOH Jun naitoh

View GitHub Profile
@naitoh
naitoh / py2rb examples
Created February 1, 2019 12:32
py2rb master 0d2fbc5a86b82707a1d83241a21af6b2cc22c0b8
-- [python] ---------
* tests/algorithms/sqrt.py
def abs(x):
if x > 0:
return x
else:
return -x
def sqrt(x):
eps = 1e-10
@naitoh
naitoh / broadcast.py
Created November 18, 2018 04:23
Numo::NArray vs numpy performance. (CentOS 7(x64) Ruby 2.5.3 Numo::NArray 0.9.1.3, Python 3.6.5 numpy 1.15.4)
$ cat broadcast.py
from benchmarker import Benchmarker
import numpy as np
## specify number of loop
with Benchmarker(10000, width=20) as bench:
@bench(None) ## empty loop
def _(bm):
x = np.ones([1000,784], dtype=np.float32)