Skip to content

Instantly share code, notes, and snippets.

View raytroop's full-sized avatar
🎯
Focusing

raytroop

🎯
Focusing
View GitHub Profile
@raytroop
raytroop / cudaDmy.cuh
Last active August 23, 2018 03:19
dummy header for cuda vscode
#pragma once
#ifdef __INTELLISENSE__
void __syncthreads();
#define KERNEL_ARG2(grid, block)
#define KERNEL_ARG3(grid, block, sh_mem)
#define KERNEL_ARG4(grid, block, sh_mem, stream)
#else
#define KERNEL_ARG2(grid, block) <<< grid, block >>>
#define KERNEL_ARG3(grid, block, sh_mem) <<< grid, block, sh_mem >>>
#define KERNEL_ARG4(grid, block, sh_mem, stream) <<< grid, block, sh_mem, stream >>>
@raytroop
raytroop / copy-deepcopy.md
Last active September 4, 2018 15:32
python deepcopy
In [15]: import copy

In [23]: ax = [[1, 2], [3, 4]]

# deepcopy
In [24]: bx = copy.deepcopy(ax)

In [25]: ax
Out[25]: [[1, 2], [3, 4]]
@raytroop
raytroop / naive_conv2d.py
Last active September 14, 2018 14:14
conv2d implementation of cs231n spring1718_assignment2_v2
def conv_forward_naive(x, w, b, conv_param):
"""
A naive implementation of the forward pass for a convolutional layer.
The input consists of N data points, each with C channels, height H and
width W. We convolve each input with F different filters, where each filter
spans all C channels and has height HH and width WW.
Input:
- x: Input data of shape (N, C, H, W)
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
1> block select:
#####################
asd asd asd asd asd;
asd asd asd asd asd;
asd asd asd asd asd;
asd asd asd asd asd;
asd asd asd asd asd;
asd asd asd asd asd;
asd asd asd asd asd;
#####################
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raytroop
raytroop / mapflat.py
Last active September 16, 2018 04:39
map and flat_map
import tensorflow as tf
# >1
input = [10, 20, 30]
ds = tf.data.Dataset.from_tensor_slices(input)
ds = ds.flat_map(lambda x: tf.data.Dataset.from_tensor_slices([x, x+1, x+2]))
element = ds.make_one_shot_iterator().get_next()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raytroop
raytroop / vanilla_forward.py
Last active September 18, 2018 04:20
numpy Computing Probabilities on HMM - vanilla method and forward algorithm based on `BinRoot/TensorFlow-Book`
from itertools import product
import numpy as np
# >1 vanilla method, computing expensive
def vanilla(initial_prob, trans_prob, obs_prob, observations):
it = list((product([0, 1], repeat=len(observations))))
it = np.array(it)
# [[0 0 0 0 0]
# [0 0 0 0 1]
# [0 0 0 1 0]
@raytroop
raytroop / btree_yield.py
Last active September 18, 2018 06:25
binary tree traversal generator
from queue import deque
class tree:
def __init__(self, x):
self.data = x
self.left = None
self.right = None