This file contains 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
""" By Matthew Baas (rf5.github.io) """ | |
import torch | |
import torch.nn.functional as F | |
def kmeans_pp_init(X, k, dist_func, tol=1e-9): | |
""" | |
`X` is (d, N) , `k` is int; | |
uses kmeanspp init from https://theory.stanford.edu/~sergei/papers/kMeansPP-soda.pdf | |
""" |
This file contains 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
# pip install fastprogress | |
# pip install pydub | |
from pydub import AudioSegment | |
from pydub.utils import mediainfo | |
from fastprogress import progress_bar | |
import os | |
import glob | |
from pathlib import Path | |
from concurrent.futures.process import ProcessPoolExecutor |
This file contains 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
class DE0_Generator(object): | |
def __init__(self, base_hz=50e6): | |
# base clock of 50MHz for DE0 board | |
self.vhdl = "" | |
self.processes = [] | |
self.signals = {} | |
self.with_statements = [] | |
self.base_hz = base_hz |
This file contains 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 math import sin, cos, exp, sqrt, pi | |
import random | |
def holder_table(di): | |
x0 = di['x0'] | |
x1 = di['x1'] | |
return -abs(sin(x0)*cos(x1)*exp(abs(1-sqrt(x0*x0+x1*x1)/pi))) | |
class RandomOptimizer(object): |
This file contains 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
""" | |
The TL;DR: | |
What is this? A function to get the global Luong-style context vector for an attention mechanism in tensorflow. | |
Use case? tensorflow's attention api's are quite restrictive to seq2seq models and aren't very flexible or | |
require training helpers and sequence feeders that must be used to use their attention api properly. | |
So, this just gives you the context vector given an rnn output sequence and a previous rnn state (traditionally the decoder's last state) | |
Note: Scoring is done between the previous hidden state and the encoder rnn's outputs and not the encoder's hidden states, | |
although for many RNNCells the output is the hidden state |