Skip to content

Instantly share code, notes, and snippets.

View huyhoang17's full-sized avatar
🎯
Focusing

Phan Hoang huyhoang17

🎯
Focusing
View GitHub Profile
@huyhoang17
huyhoang17 / how-to-download-from-pan-baidu.md
Created August 30, 2021 15:53
How to download from pan.baidu without account

How to download from pan.baidu.com

Disclaimer:

  • This methods uses a 3rd party website: https://baidu.kinh.cc/.
  • I don't know chinese and after one day of searching for a method I finally found this. I don't know how safe this website is but it does the job.
  • Do it on your own responsibility. I have no idea about possible copyright (if there is such a thing in China) and other stuff regarding to this.

Steps

1. Open the website mentioned above and fill out fields as following:

#!/usr/bin/env python
from __future__ import print_function
import argparse
import numpy as np
import time
tt = time.time()
import cv2
from grpc.beta import implementations
@huyhoang17
huyhoang17 / MNE_CSP.py
Created April 24, 2019 03:44 — forked from alexandrebarachant/MNE_CSP.py
CSP for Grasp and lift challenge
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 29 14:00:37 2015
@author: alexandrebarachant
"""
import numpy as np
import pandas as pd
from mne.io import RawArray
# -*- coding: utf-8 -*-
"""
Created on Fri May 05 04:12:36 2017
@author: ADubey4
"""
from __future__ import unicode_literals, print_function
import gensim
from gensim.parsing import PorterStemmer
@huyhoang17
huyhoang17 / export_saved_model.py
Created March 28, 2019 12:07 — forked from himanshurawlani/export_saved_model.py
Script to convert Keras models to TensorFlow Serving SavedModel format
import tensorflow as tf
# The export path contains the name and the version of the model
tf.keras.backend.set_learning_phase(0) # Ignore dropout at inference
model = tf.keras.models.load_model('./inception.h5')
export_path = '../my_image_classifier/1'
# Fetch the Keras session and save the model
# The signature definition is defined by the input and output tensors
# And stored with the default serving key
@huyhoang17
huyhoang17 / layers.py
Created January 11, 2019 09:34 — forked from DylanModesitt/layers.py
Attentive LSTM keras
from keras import backend as K
from keras import regularizers, constraints, initializers, activations
from keras.layers.recurrent import RNN, Layer, _generate_dropout_mask, _generate_dropout_ones
from keras.engine import InputSpec
from keras.legacy import interfaces
import warnings
# Copied from original keras source
def _time_distributed_dense(x, w, b=None, dropout=None,
@huyhoang17
huyhoang17 / custom_layers.md
Created January 11, 2019 08:15
Blog - Custom layers in Keras

Building custom layers in Keras

About Keras

Keras is currently one of the most commonly used deep learning libraries today. And part of the reason why it's so popular is its API. Keras was built as a high-level API for other deep learning libraries ie Keras as such does not perform low-level tensor operations, instead provides an interface to its backend which are built for such operations. This allows Keras to abstract a lot of the underlying details and allows the programmer to concentrate on the architecture of the model. Currently Keras supports Tensorflow, Theano and CNTK as its backends.

Let's see what I mean. Tensorflow is one of the backends used by Keras. Here's the code for MNIST classification in TensorFlow and Keras. Both models are nearly identical and applies to the same problem. But if you compare the codes you g

@huyhoang17
huyhoang17 / pq.py
Created November 13, 2018 15:59
PQ code from Product Quantization paper
import numpy as np
from scipy.cluster.vq import vq, kmeans2
from scipy.spatial.distance import cdist
def train(vec, M, Ks=256):
Ds = int(vec.shape[1] / M)
codeword = np.empty((M, Ks, Ds), np.float32)
for m in range(M):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@huyhoang17
huyhoang17 / live_loss_plot_keras.ipynb
Created November 4, 2018 16:51 — forked from stared/live_loss_plot_keras.ipynb
Live loss plot for training models in Keras (see: https://github.com/stared/livelossplot/ for a library)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.