Skip to content

Instantly share code, notes, and snippets.

@poweic
poweic / sym2cpp.m
Created April 20, 2016 18:13
A simple script that can convert MATLAB symbolic expression to C implementation.
function [] = sym2cpp( expr, filename, output_size, n_digits )
%SYM2CPP Summary of this function goes here
% Detailed explanation goes here
if ~exist('n_digits', 'var')
n_digits = 64;
end
[dim1, dim2] = size(expr);
@poweic
poweic / multithread_reader.py
Created March 14, 2017 04:44
Example of multi-thread image reader using TensorFlow
#!/usr/bin/python
import sys
from time import time
import tensorflow as tf
num_threads = int(sys.argv[1])
db_dir = "/Data3/cityscapes/scp/"
image_scp = db_dir + "train.img.scp"
@poweic
poweic / tf_map_bug.py
Created April 25, 2019 23:27
Code snippet to recreate memory leak bug when .map is used with AUTOTUNE
#! /usr/bin/env python3
import tensorflow as tf
zeros = [0] * 10
dataset = (
tf.data.Dataset.from_tensor_slices(zeros)
.map(lambda x: x, num_parallel_calls=tf.data.experimental.AUTOTUNE)
# .map(lambda x: x)
.batch(1)
Frame id: 714, timestamp: 1563558646180371, hands: 1, fingers: 5, tools: 0, gestures: 0
Right hand, id 1, position: (27.0209, 199.338, 144.782)
pitch: 34.333859 degrees, roll: -11.224934 degrees, yaw: 5.460586 degrees
Arm direction: (0.231353, 0.40452, -0.884782), wrist position: (30.8451, 171.972, 190.071), elbow position: (-29.7334, 66.0506, 421.746)
Thumb finger, id: 10, length: 50.542061mm, width: 19.638296mm
Bone: Metacarpal, start: (1.70232, 166.527, 187.598), end: (1.70232, 166.527, 187.598), direction: (0, 0, 0)
Bone: Proximal, start: (1.70232, 166.527, 187.598), end: (-27.2441, 180.504, 151.401), direction: (0.597947, -0.28873, 0.747726)
Bone: Intermediate, start: (-27.2441, 180.504, 151.401), end: (-39.3076, 187.096, 121.328), direction: (0.364834, -0.199364, 0.909478)
Bone: Distal, start: (-39.3076, 187.096, 121.328), end: (-42.346, 189.514, 98.9661), direction: (0.133868, -0.106497, 0.98526)
Index finger, id: 11, length: 57.031078mm, width: 18.758501mm