Skip to content

Instantly share code, notes, and snippets.

View SynthAether's full-sized avatar

Zyser SynthAether

View GitHub Profile
@endolith
endolith / FIR_filter_NN.py
Last active May 13, 2025 16:20
Neural network learning FIR filter
"""
Train a neural network to learn an FIR filter.
Created on Fri Aug 3 15:00:40 2018
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.callbacks import Callback
import numpy as np
from scipy import signal
@bitonic
bitonic / vectorized-atan2f.cpp
Last active October 18, 2025 20:21
Vectorized & branchless atan2f
// Copyright (c) 2021 Francesco Mazzoli <f@mazzo.li>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@jeasinema
jeasinema / weight_init.py
Last active November 22, 2024 07:17
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):
'''
@fengye
fengye / find_similarities.py
Last active May 27, 2019 07:52
Using cross correlation to find similarity in two audios. Useful in echo cancellation.
import audio_io
import numpy
audio1, _ = audio_io.ReadWavFile('voice_nodelay.wav')
audio1 = audio1.ravel()
audio2, _ = audio_io.ReadWavFile('voice_mic_blend3.wav')
audio2 = audio2.ravel()
# Truncate all signals same length, then pad to avoid boundary effects.
@rtqichen
rtqichen / pytorch_weight_norm.py
Last active May 11, 2023 06:58
Pytorch weight normalization - works for all nn.Module (probably)
## Weight norm is now added to pytorch as a pre-hook, so use that instead :)
import torch
import torch.nn as nn
from torch.nn import Parameter
from functools import wraps
class WeightNorm(nn.Module):
append_g = '_g'
append_v = '_v'
@luzfcb
luzfcb / clean_py.sh
Last active February 29, 2024 05:50 — forked from joelverhagen/clean_py.sh
Recursively removes all .pyc files and __pycache__ directories in the current directory
#!/bin/sh
# recursively removes all .pyc , .pyo files and __pycache__ directories in the current
# directory
find . | \
grep -E "(__pycache__|\.pyc$|\.pyo$)" | \
xargs rm -rf
# or, for copy-pasting:
@anantzoid
anantzoid / pixelcnn_decoder.md
Created November 19, 2016 08:14
Summary for Conditional Image Generation with PixelCNN Decoder

Conditional Image Generation with PixelCNN Decoder

Implemenetation:

What

  • New image density model based on PixelCNN
  • Can generate variety of images from text embeddings or CNN layer weights
  • Serves as decoder in image autoencoder
  • Gated PixelCNN: Matches PixelRNN accuracy
@guozhou
guozhou / persistent.cpp
Last active November 22, 2024 06:46
A minimum CUDA persistent thread example.
#include <iostream>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
// GTS450 sm_21
#define NUM_SM 4 // no. of streaming multiprocessors
#define NUM_WARP_PER_SM 48 // maximum no. of resident warps per SM
#define NUM_BLOCK_PER_SM 8 // maximum no. of resident blocks per SM
#define NUM_BLOCK NUM_SM * NUM_BLOCK_PER_SM
#define NUM_WARP_PER_BLOCK NUM_WARP_PER_SM / NUM_BLOCK_PER_SM
@karpathy
karpathy / min-char-rnn.py
Last active October 23, 2025 16:55
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@hbsdev
hbsdev / clean_py.sh
Last active June 7, 2025 15:46 — forked from joelverhagen/clean_py.sh
Recursively remove all .pyc files and __pycache__ directories in the current directory.
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | grep -E "(__pycache__|\.pyc$)" | xargs rm -rf