Skip to content

Instantly share code, notes, and snippets.

View bdqnghi's full-sized avatar
🧧
Focusing

Nghi D. Q. Bui bdqnghi

🧧
Focusing
View GitHub Profile
@bdqnghi
bdqnghi / test_thread.py
Created July 29, 2021 12:46
Read multiple files in multiple threads, process and write into a single file
import codecs
import queue # or queue in Python 3
import threading
import os
class PrintThread(threading.Thread):
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queue
@bdqnghi
bdqnghi / split_train_test_val.py
Last active November 2, 2021 17:25
Split train test val script
import shutil
import os
import random
from random import shuffle
from shutil import copyfile
from concurrent.futures import ThreadPoolExecutor
# ROOT = "/home/nghibui/codes/bi-tbcnn/"
src_dir = "train"
tgt_dir = "train_val"
@bdqnghi
bdqnghi / text.txt
Last active April 5, 2020 19:01
Note on caps net
1) Input MNIST: [28 x 28 x 1] ( 1 color channel)
2) Kernel = [9x9]
3) Apply kernel to input 256 times:
(28 - 9 ) + 1 = 20
Output is 256 x 20 x 20
4) Relu: 256 x 20 x 20
5) Apply kernel again with stride = 2:
((20 - 9) + 1) = 6
Output is 256 x 6 x 6
6) We’re going to cut the stack up into 32 decks with 8 cards each deck.
@bdqnghi
bdqnghi / weight_init.py
Created September 26, 2018 12:14 — forked from jeasinema/weight_init.py
A simple script for parameter initialization for PyTorch
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.init as init
def weight_init(m):
'''
@bdqnghi
bdqnghi / rank_metrics.py
Created May 22, 2018 19:15 — forked from bwhite/rank_metrics.py
Ranking Metrics
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
0x25b93ff09948D6E1B40aA0190f5B3bA0B3d65139
0x25b93ff09948D6E1B40aA0190f5B3bA0B3d65139
0x698e692B557310fE216127FF9Dd65E06782f6425
@bdqnghi
bdqnghi / gist:54b5ffeb22447336bde51f61d9fcedf7
Created September 27, 2017 17:56 — forked from brendano/gist:963c826e7109a5e50d54
papers that do NLP-like stuff with source code
NLP and source code papers, very scattered and partial listing
(collected by Nathan Schneider and Brendan O'Connor)
ICML 2014
Maddison and Tarlow
Structured Generative Models of Natural Source Code
http://jmlr.org/proceedings/papers/v32/maddison14.pdf
ACL 2013