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 / tf_gradient_clip_lr_decay.py
Created September 2, 2018 08:31 — forked from InnerPeace-Wu/tf_gradient_clip_lr_decay.py
ways to do gradients clipping and learning rate decay in tensorflow
import tensorflow as tf
#aplly exponential decay on learning rate
global_step = tf.Variable(0, trainable=False)
stater_learning_rate = lr #for start
learning_rate = tf.train.exponential_decay(starter_learning_rate, global_step,
decay_steps, decay_rate, staircase=True)
optimizer = tf.train.AdamOptimizer(learning_rate)
@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 / bn.py
Last active April 8, 2019 09:34
Implement Batch Normalization with low API (https://blog.csdn.net/shuzfan/article/details/79054561)
# 实现Batch Normalization
def bn_layer(x, is_training, name='BatchNorm', moving_decay=0.9, eps=1e-5):
# 获取输入维度并判断是否匹配卷积层(4)或者全连接层(2)
shape = x.shape
assert len(shape) in [2, 4]
param_shape = shape[-1]
with tf.variable_scope(name):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raytroop
raytroop / tqdmTUT.md
Last active October 23, 2018 07:31
tqdm pattern

tqdm is very versatile and can be used in a number of ways. The three main ones are given below.

Iterable-based

Wrap tqdm() around any iterable:

@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)
syntax on
colorscheme desert
set number
set hlsearch
set tabstop=4 //实际的tab键占用的space
set softtabstop=4 //当敲一个tab键时所占用的space
set shiftwidth=4 //自动缩进的space
//set expandtab //将tab转化为space
set enc=utf-8
set guifont=Monospace\ 12
# /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;
#####################