This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A weighted version of categorical_crossentropy for keras (2.0.6). This lets you apply a weight to unbalanced classes. | |
@url: https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d | |
@author: wassname | |
""" | |
from keras import backend as K | |
def weighted_categorical_crossentropy(weights): | |
""" | |
A weighted version of keras.objectives.categorical_crossentropy | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://stackoverflow.com/a/518232/4102479 | |
# This is better approach, compared to unidecode, though unidecode provide acceptable result in almost every cases | |
import unicodedata | |
import string | |
all_letters = string.ascii_letters + " .,;'" | |
nb_letter = len(all_letters) | |
print(all_letters, len(all_letters)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.colab import drive | |
drive.mount('/content/drive') | |
!rm *.json | |
from google.colab import files | |
files.upload() # upload kaggle.json | |
!pip install kaggle | |
!mkdir -p ~/.kaggle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
""" This work is licensed under a Creative Commons Attribution 3.0 Unported License. | |
Frank Zalkow, 2012-2013 """ | |
# Source: http://www.frank-zalkow.de/en/code-snippets/create-audio-spectrograms-with-python.html?ckattempt=1&i=1 | |
import numpy as np | |
from matplotlib import pyplot as plt | |
import scipy.io.wavfile as wav |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function is used to reduce memory of a pandas dataframe | |
# The idea is cast the numeric type to another more memory-effective type | |
# For ex: Features "age" should only need type='np.int8' | |
# Source: https://www.kaggle.com/gemartin/load-data-reduce-memory-usage | |
def reduce_mem_usage(df): | |
""" iterate through all the columns of a dataframe and modify the data type | |
to reduce memory usage. | |
""" | |
start_mem = df.memory_usage().sum() / 1024**2 | |
print('Memory usage of dataframe is {:.2f} MB'.format(start_mem)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy a list of file (from file_id_list) from src to dest | |
cat file_id_list | awk '{system("cp " $1 " <dest_dir")}' | |
# total time of audio file within a directory | |
soxi -D *.wav | awk '{sum+=$1} END {print sum}' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <S-Left> :action EditorLeftWithSelection<CR> | |
nnoremap <S-Right> :action EditorRightWithSelection<CR> | |
nnoremap <S-Up> :action EditorUpWithSelection<CR> | |
nnoremap <S-Down> :action EditorDownWithSelection<CR> | |
inoremap <S-Left> <C-O>:action EditorLeftWithSelection<CR> | |
inoremap <S-Right> <C-O>:action EditorRightWithSelection<CR> | |
inoremap <S-Up> <C-O>:action EditorUpWithSelection<CR> | |
inoremap <S-Down> <C-O>:action EditorDownWithSelection<CR> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#WINE with error (OLE error 80040154) | |
wget http://winetricks.org/winetricks | |
chmod +x winetricks | |
winetricks -v vcrun6 winetricks -v msxml4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
from numpy.fft import rfft | |
from numpy import argmax, mean, diff, log, nonzero | |
from scipy.signal import blackmanharris, correlate | |
from time import time | |
import sys | |
try: | |
import soundfile as sf | |
except ImportError: | |
from scikits.audiolab import flacread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright @ nguyenvanhieu.vn | |
Thằng code java này vẫn giữ được lower/upper case | |
Code này ngon hơn, check đúng trường hợp cần thêm dấu thì mới thêm | |
Tuy nhiên code python ở dưới không check nhưng vẫn chưa thấy bugs nào hết :v | |
*/ | |
package utils; | |
import java.util.*; |
OlderNewer