Skip to content

Instantly share code, notes, and snippets.

View YusukeSuzuki's full-sized avatar

Yusuke Suzuki YusukeSuzuki

View GitHub Profile
import random
from random import choice
import tensorflow as tf
import numpy as np
import pyfastnoisesimd as fns
def ch3_fractal_noise(size_chw, seed,
color_gain_min=0.5, color_gain_max=1.0,
octaves_min=3, octaves_max=6,
@YusukeSuzuki
YusukeSuzuki / bench.txt
Last active April 27, 2021 09:34
GCP A100 pytorch 1.8.1 benchmark
$ python3 -m fastrnns.bench
Namespace(cnns=None, cuda_pointwise_block_count=None, cuda_pointwise_block_size=None, cuda_pointwise_loop_level=None, device='cuda', executor=None, fuser='te', group=['cnns', 'rnns'], hiddenSize=512, inputSize=512, miniBatch=64, nloops=100, numLayers=1, print_json=None, rnns=None, sep=' ', seqLength=100, variable_lstms=False, warmup=10)
Benchmarking LSTMs...
name avg_fwd std_fwd info_fwd avg_bwd std_bwd info_bwd
cudnn 3.384 0.2857 None 3.613 0.06748 None
aten 9.766 0.415 None 18.85 0.1766 None
jit 10.48 0.1774 None 18.53 0.8058 None
jit_premul 8.273 0.07718 None 14.63 0.1991 None
jit_premul_bias 8.143
@YusukeSuzuki
YusukeSuzuki / dct_data.py
Created February 12, 2021 11:36
2D DCT basis based Upsample layer
DCT_TABLE_BUFFER = b"\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\xbe\x14\xfb?0\xdb\xd4?\xda9\x8e?\xc0\xc5\xc7>\xc0\xc5\xc7\xbe\xda9\x8e\xbf0\xdb\xd4\xbf\xbe\x14\xfb\xbf\xbe\x14\xfb?0\xdb\xd4?\xda9\x8e?\xc0\xc5\xc7>\xc0\xc5\xc7\xbe\xda9
@YusukeSuzuki
YusukeSuzuki / test.xonsh
Created May 27, 2019 11:04
my first xonsh script
directories = [
$(readlink -m ~/Downloads).strip(),
$(readlink -m ~/Desktop).strip(),
]
for d in directories:
ls -l @(p)
import os
import tensorflow as tf
from tensorflow.contrib import tpu
from tensorflow.contrib.cluster_resolver import TPUClusterResolver
IMAGE_FILES='gs://MY_OWN_GCS_BUCKET/celeba/files.txt'
SIZE=(128,128)
BATCH=128
LR=1e-4
@YusukeSuzuki
YusukeSuzuki / log.txt
Created November 21, 2018 03:10
my TF gan training crash log
global_step = 243830
global_step = 243840
global_step = 243850
2018-11-20 23:42:59.740578: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 301.50MiB. The caller indicates that this is not a failure, bu
t may mean that there could be performance gains if more memory were available.
2018-11-20 23:42:59.741211: W tensorflow/core/common_runtime/bfc_allocator.cc:219] Allocator (GPU_0_bfc) ran out of memory trying to allocate 301.50MiB. The caller indicates that this is not a failure, bu
t may mean that there could be performance gains if more memory were available.
2018-11-20 23:42:59.741553: E tensorflow/stream_executor/cuda/cuda_dnn.cc:81]
Traceback (most recent call last):
File "/home/yusuke/.pyenv/versions/tf1.10/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call
import tensorflow as tf
import numpy as np
from keras.layers import Conv2D
img = tf.constant(np.ones([16,128,128,3]), dtype=tf.float32)
conv = Conv2D(32, 3)
y = conv(img)
graph = tf.get_default_graph()
@YusukeSuzuki
YusukeSuzuki / cv2_load_img.py
Created October 2, 2018 04:52
python3 load image speed test. val2017 is coco dataset image directory.
from pathlib import Path
import cv2
d = Path('val2017')
for f in d.glob('*.jpg'):
img = cv2.imread(str(f))
import tensorflow as tf
import numpy as np
import sys
# simple k-means clustering with tensorflow
# this is my practice code for tensorflow graph coding
# parameters
K_SIZE = 5
#!/usr/bin/env python3
# This is full TensolFlow version of Ryan Dahl's Automatic Colorization.
# The original is here -> http://tinyclouds.org/colorize/
import sys
import tensorflow as tf
INPUT_EDGE = 224
INPUT_FILE = 'shark.jpg'
OUTPUT_FILE = 'shark-color.jpg'