This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
def get_logger(name=None): | |
"""return a logger | |
""" | |
logger = logging.getLogger(name) | |
logger.setLevel(logging.INFO) | |
sh = logging.StreamHandler() | |
sh.setLevel(logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""RecordDb is an esay interface to save (image, label) data to `mx.record` | |
""" | |
import random | |
import mxnet as mx | |
class RecDb(object): | |
"""Interface to save (image, label) to `mx.record` | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing as mp | |
class Job(object): | |
'''Job present a data processing pipeline with mapper and reducer | |
''' | |
def __init__(self, name, mapper, reducer, worker_n): | |
'''initialize Job object with given mapper and reducer | |
Parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__global__ void reduce_kernel(float* d_in, int n, float* d_out) { | |
extern __shared__ float shared_mem[]; | |
int tid = threadIdx.x; | |
int i = threadIdx.x + blockDim.x * blockIdx.x; | |
if (i < len) { | |
shared_mem[tid] = d_in[i]; | |
} | |
else { | |
shared_mem[tid] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### CMakeLists.txt for CUDA | |
cmake_minimum_required(VERSION 2.8) | |
find_package(CUDA QUIET REQUIRED) | |
# Pass options to NVCC | |
set( | |
CUDA_NVCC_FLAGS | |
${CUDA_NVCC_FLAGS}; | |
-O3 -gencode arch=compute_22,code=sm_22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
ps = [ | |
0.0000008110673199286165000000000000000000, | |
0.0000162907226016170940000000000000000000, | |
0.0024177576053697383000000000000000000000, | |
0.0000000054649286143693143000000000000000, | |
0.0003272079103201879800000000000000000000, | |
0.0000000148552161462659780000000000000000, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"color_scheme": "Packages/Theme - Afterglow/Afterglow.tmTheme", | |
"default_line_ending": "system", | |
"font_size": 14, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"tab_size": 2, | |
"tabs_medium": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#define cudaCheckError(ans) { cudaAssert((ans), __FILE__, __LINE__); } | |
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true) | |
{ | |
if (code != cudaSuccess) | |
{ | |
fprintf(stderr, "CUDA Error: %s at %s:%d\n", | |
cudaGetErrorString(code), file, line); | |
if (abort) exit(code); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
#include <stdio.h> | |
#include <stdarg.h> | |
void LOG(const char* fmt, ...) { | |
va_list args; | |
va_start(args, fmt); | |
char msg[256]; | |
vsprintf(msg, fmt, args); | |
va_end(args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
/*! \brief Timer */ | |
class Timer { | |
using Clock = std::chrono::high_resolution_clock; | |
public: | |
/*! \brief start or restart timer */ | |
inline void Tic() { | |
start_ = Clock::now(); | |
} |
NewerOlder