Skip to content

Instantly share code, notes, and snippets.

View trungkak's full-sized avatar

Trung Lê Hoàng trungkak

View GitHub Profile
@trungkak
trungkak / min-char-rnn.py
Created October 21, 2017 18:34 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@trungkak
trungkak / tf.sh
Created November 23, 2017 21:09
Tensorflow GPU installation on Ubuntu 16.04
# 1. Install CUDA
# Preparation
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tmux build-essential gcc g++ make binutils
sudo apt-get install software-properties-common
# Download Cuda toolkit (Nvidia driver included)
cd ~/Downloads
# Download CUDA 8.0 from this https://developer.nvidia.com/cuda-80-ga2-download-archive, not 9.0
@trungkak
trungkak / install-opencv-2.4.13.4-in-ubuntu.sh
Last active December 12, 2017 10:00 — forked from arthurbeggs/install_opencv2_ubuntu.sh
Install opencv-2.4.13.4 in Ubuntu
#!/bin/bash
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
$ sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev
$ pip install numpy
$ pip install scipy
$ pip install scikit-image
$ pip install dlib
#Locate libmkl_rt.so
for dir in $(find . -type d)
do
if [ $(ls -l "$dir" | grep '\.jpg$' | wc -l) -ge 3 ]
then
cp -r $dir ../slfw
fi
done
@trungkak
trungkak / pattern
Created March 3, 2018 18:18
Sentences splitting regex patterns
Pattern pattern = Pattern.compile(
"# Match a sentence ending in punctuation or EOS.\n" +
"[^.!?\\s] # First char is non-punct, non-ws\n" +
"[^.!?]* # Greedily consume up to punctuation.\n" +
"(?: # Group for unrolling the loop.\n" +
" [.!?] # (special) inner punctuation ok if\n" +
" (?!['\"]?\\s|$) # not followed by ws or EOS.\n" +
" [^.!?]* # Greedily consume up to punctuation.\n" +
")* # Zero or more (special normal*)\n" +
"[.!?]? # Optional ending punctuation.\n" +
@trungkak
trungkak / hello_sequence.py
Created March 22, 2018 17:59 — forked from pannous/hello_sequence.py
Simple "Hello World" for tensorflow seq2seq model
"""Sequence-to-sequence model with an attention mechanism."""
# see https://www.tensorflow.org/versions/r0.10/tutorials/seq2seq/index.html
# compare https://github.com/tflearn/tflearn/blob/master/examples/nlp/seq2seq_example.py
from __future__ import print_function
import numpy as np
import tensorflow as tf
vocab_size=256 # We are lazy, so we avoid fency mapping and just use one *class* per character/byte
target_vocab_size=vocab_size
learning_rate=0.1
@trungkak
trungkak / neo4j_cypher_cheatsheet.md
Created April 23, 2018 08:56 — forked from DaniSancas/neo4j_cypher_cheatsheet.md
Neo4j's Cypher queries cheatsheet

Neo4j Tutorial

Fundamentals

Store any kind of data using the following graph concepts:

  • Node: Graph data records
  • Relationship: Connect nodes (has direction and a type)
  • Property: Stores data in key-value pair in nodes and relationships
  • Label: Groups nodes and relationships (optional)
@trungkak
trungkak / PostgreSQL Challenges Completed.md
Created April 29, 2018 16:07 — forked from samlexrod/PostgreSQL Challenges Completed.md
Here I show my commitment to challenge myself to building better queries from places such as codewars, hacker rank, or others.

PostgreSQL Challenges

  1. You need to build a pivot table WITHOUT using CROSSTAB function. Having two tables products and details you need to select a pivot table of products with counts of details occurrences (possible details values are ['good', 'ok', 'bad'].
SELECT
  distinct pro.name,
  (SELECT count(*) FROM details det2 WHERE det2.detail = 'good' AND det2.product_id = det.product_id) AS good,
  (SELECT count(*) FROM details det2 WHERE det2.detail = 'ok' AND det2.product_id = det.product_id) AS ok,
 (SELECT count(*) FROM details det2 WHERE det2.detail = 'bad' AND det2.product_id = det.product_id) AS bad
@trungkak
trungkak / tfpdf.py
Created June 28, 2018 18:52 — forked from bllchmbrs/tfpdf.py
TF IDF Explained in Python Along with Scikit-Learn Implementation
from __future__ import division
import string
import math
tokenize = lambda doc: doc.lower().split(" ")
document_0 = "China has a strong economy that is growing at a rapid pace. However politically it differs greatly from the US Economy."
document_1 = "At last, China seems serious about confronting an endemic problem: domestic violence and corruption."
document_2 = "Japan's prime minister, Shinzo Abe, is working towards healing the economic turmoil in his own country for his view on the future of his people."
document_3 = "Vladimir Putin is working hard to fix the economy in Russia as the Ruble has tumbled."