Skip to content

Instantly share code, notes, and snippets.

View seungwonpark's full-sized avatar

Seung-won Park seungwonpark

View GitHub Profile
# -*- coding: utf-8 -*-
import os
import json
import torch
import pickle
import requests
import numpy as np
import torch as t
import torch.nn as nn
def initi(var_shape):
real_part = nprand.rand(var_shape[0], var_shape[1], var_shape[2], var_shape[3])
imag_part = nprand.rand(var_shape[0], var_shape[1], var_shape[2], var_shape[3])
return tf.constant_initializer(real_part + imag_part*1.0j)
def lrelu(tensor_in): # this is not leaky-relu
temp_real = tf.real(tensor_in)
temp_imag = tf.imag(tensor_in)
return tf.complex(temp_real, temp_imag)
@mkocabas
mkocabas / coco.sh
Created April 9, 2018 09:41
Download COCO dataset. Run under 'datasets' directory.
mkdir coco
cd coco
mkdir images
cd images
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/zips/test2017.zip
wget http://images.cocodataset.org/zips/unlabeled2017.zip
@carlthome
carlthome / Signal reconstruction from spectrograms.ipynb
Created May 31, 2018 13:53
Try to recover audio from filtered magnitudes when phase information has been lost.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@20chan
20chan / 5writeup.md
Last active June 14, 2019 14:55
국가암호공모전 롸업

프로그램에서 A를 25번 입력하면 UIYOAUOIOEIAYEUYOIEYEAUYA 이 나온다. 이 값을 EncVowel 테이블과 비교하여 찾아보면, 초기 vowel_position의 값은 8임을 알 수 있다. 이때의 EncVowel 테이블의 값은 {6, 3, 5, 2, 1, 4} 이다.

프로그램을 실행하고 처음 A, E, I, O, U, Y 의 모음을 입력하여 나오는 값은 각각 U, E, I, Y, O, A 이다. 코드의 ct_num 에 해당되는 모음의 숫자 값은 각각 4, 1, 2, 5, 3, 0 이다. 그러면 테이블과 비교하여 이 값이 나오기 위한 인덱스 (perm_num) 값은 각각 2, 3, 1, 0, 5, 4 이다. 그렇다면 PermVowel 의 값은 {3, 4, 2, 1, 6, 5} 임을 알 수 있다.

같은 방식으로 자음도 구할 수 있다. 첫번째 글자로 자음들 B, C, D, ..., Z의 결과값은 JWHZCXVLGSBQRMPFKNTD 이고 두번째 글자로 자음들의 결과값은 MFKXVPZTHDLNGJWBSCQR 이다. 이때 세개의 테이블 중 첫번째 테이블만이 인덱스가 변했을 경우와 두번째 테이블과 첫번째 테이블 둘다 인덱스가 변했을 경우가 있지만 일단 첫번째 경우만 생각해주고 안되면 두번째 케이스를 생각해 보는 것으로 한다.

@mutiann
mutiann / stepwise.py
Last active August 29, 2022 08:44
Stepwise Monotonic Attention
'''
Implementation for https://arxiv.org/abs/1906.00672
Tips: The code could be directly used in place of BadahnauMonotonicAttention in Tensorflow codes. Similar to its
base class in the Tensorflow seq2seq codebase, you may use "hard" for hard inference, or "parallel" for training or
soft inference. "recurrent" mode in BadahnauMonotonicAttention is not supported.
If you have already trained another model using BadahnauMonotonicAttention, the model could be reused, otherwise you
possibly have to tune the score_bias_init, which, similar to that in Raffel et al., 2017, is determined a priori to
suit the moving speed of the alignments, i.e. speed of speech of your training corpus in TTS cases. So
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
from torchvision import datasets, transforms
import math
import numpy as np
# Hardcoded variables for hyperfan init