Skip to content

Instantly share code, notes, and snippets.

View liketheflower's full-sized avatar

jimmy shen liketheflower

View GitHub Profile
@liketheflower
liketheflower / readme.md
Created April 25, 2017 19:20 — forked from baraldilorenzo/readme.md
VGG-19 pre-trained model for Keras

##VGG19 model for Keras

This is the Keras model of the 19-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@liketheflower
liketheflower / readme.md
Created April 25, 2017 19:20 — forked from baraldilorenzo/readme.md
VGG-19 pre-trained model for Keras

##VGG19 model for Keras

This is the Keras model of the 19-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

@liketheflower
liketheflower / ec2-cuda-setup.bash
Created June 13, 2017 01:21 — forked from avtomaton/ec2-cuda-setup.bash
amazon AMI CUDA setup
#!/bin/bash
NVIDIA_DRIVER_VERSION=352.63
NVIDIA_CUDA_VERSION=7.5
NVIDIA_CUDA_FULL_VERSION=7.5.18
sudo yum update -y
sudo yum groupinstall -y "Development tools"
sudo yum install kernel-devel-`uname -r`
@liketheflower
liketheflower / vim.markdown
Created April 20, 2018 20:46 — forked from socketwiz/vim.markdown
Vim cheat sheet

motions

motion description
h Count characters left
l Count characters right
^ To the first character of the line
$ To the last character of the line
f<char> To the counth character occurrence to the right. F<char> to the counth character occurrence to the left
t<char> To 1 character just before the counth character occurrence to the right
@liketheflower
liketheflower / vim-cheatsheet.md
Created May 20, 2018 01:28 — forked from 0xadada/README.md
VIM movement, keyboard commands and shortcuts
@liketheflower
liketheflower / cuda_installation_on_ubuntu_18.04
Created June 30, 2019 06:35 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
cuda 9.0 complete installation procedure for ubuntu 18.04 LTS
#!/bin/bash
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
from functools import lru_cache
@lru_cache(None)
def fib_top_down(n):
if n==0: return 0
if n==1: return 1
return fib_top_down(n-1)+fib_top_down(n-2)
def fib_bottom_up(n):
if n==0: return 0
if n==1: return 1
# dp bottom up
class Solution:
def numWays(self, steps: int, arrLen: int) -> int:
MOD = 1000000007
if arrLen == 1:return 1
n = min(251, arrLen)
dp = [[0 for x in range(steps+1)] for y in range(n)]
dp[0][0] = 1
for i in range(1, steps+1):
dp[0][i] = (dp[0][i-1]+dp[1][i-1]) % MOD
"""
DP top down
dp(pos, step) = sum(dp(pos+1, step-1), dp(pos-1, step-1), dp(pos, step-1))
"""
from functools import lru_cache
class Solution:
def numWays(self, steps: int, arrLen: int) -> int:
MOD = 10**9 + 7
@lru_cache(None)
def dp(pos, steps):
class Solution:
def numWays(self, steps: int, arrLen: int) -> int:
MOD = 10**9 + 7
POS = min(steps//2+1, arrLen)
dp = collections.defaultdict(int)
def bfs(pos, step):
cur_level = {(pos, step)}
dp[(pos, step)] = 1
while cur_level:
nxt_level = set()