Skip to content

Instantly share code, notes, and snippets.

Avatar

Liangfu Chen liangfu

View GitHub Profile
@liangfu
liangfu / vta_datapath.json
Created Nov 8, 2019
VTA Datapath in Yosys JSON Format; (Generate Block Diagram from https://nturley.github.io/netlistsvg )
View vta_datapath.json
{
creator: "Yosys 0.5+220 (git sha1 94fbaff, emcc -Os)",
modules: {
VTAShell: {
ports: {
io_host_r: {
direction: "output",
bits: [
0
]
@liangfu
liangfu / strip_comment.py
Created Sep 22, 2019
Strip Comment Sections in Chisel Generated Verilog files
View strip_comment.py
#!/usr/bin/env python3
import os, sys
out = ""
with open(sys.argv[1], 'r') as fp:
lines = fp.readlines()
for idx, line in enumerate(lines):
end = line.find(" // @[")
line = line[:end] + '\n'
out += line
View lua-amalgamation.c
/*
* one.c -- Lua core, libraries, and interpreter in a single file (Lua 5.3)
*/
/* default is to build the full interpreter */
#ifndef MAKE_LIB
#ifndef MAKE_LUAC
#ifndef MAKE_LUA
#define MAKE_LUA
#endif
@liangfu
liangfu / mobilenet.md
Created Dec 29, 2017
mobilenet model zoo
View mobilenet.md

MobileNet_v1

MobileNets are small, low-latency, low-power models parameterized to meet the resource constraints of a variety of use cases. They can be built upon for classification, detection, embeddings and segmentation similar to how other popular large scale models, such as Inception, are used. MobileNets can be run efficiently on mobile devices with TensorFlow Mobile.

MobileNets trade off between latency, size and accuracy while comparing favorably with popular models from the literature.

alt text

Pre-trained Models

@liangfu
liangfu / winograd.py
Created Nov 19, 2017
winograd convolution in numpy
View winograd.py
#!/usr/bin/python
# Copyright 2015-2016 Nervana Systems Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@liangfu
liangfu / ffmpeg.md
Created May 24, 2017 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files
View ffmpeg.md

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@liangfu
liangfu / utility.h
Created Aug 25, 2016
Get current time in formatted string with cross-platform C/C++, while avoid using c++11 classes.
View utility.h
#include <string>
#include <ctime>
#if defined WIN32
#include <windows.h>
#include <stdint.h>
static int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
SYSTEMTIME system_time;
@liangfu
liangfu / pg-pong.py
Created Jun 1, 2016 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
View pg-pong.py
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
@liangfu
liangfu / hash.c
Created May 24, 2016
simple hash string code in c
View hash.c
char num2char(size_t num){
char res = 0; int val = num%62;
if (val<10){ res = val+48;
}else if (val>=10&&val<36){ res = val+65-10;
}else if (val>=36&&val<62){ res = val+97-36;
}return res;
}
void swap(char & a, char & b){char t=b;b=a;a=t;}
void hash(char * src, char * dst, int sz){
memcpy(dst,src,32);
@liangfu
liangfu / MLPdemo.m
Last active Apr 29, 2016
demonstration of multi-layer perceptron with gradient checkings enabled
View MLPdemo.m
function MLPdemo()
net.alpha=0.002;
net.maxiter=200;
% hyperbolic - input layer
net.layer{1}.forward = @tanh_forward;
net.layer{1}.backward = @tanh_backward;
net.layer{1}.alpha=net.alpha;
You can’t perform that action at this time.