Skip to content

Instantly share code, notes, and snippets.

View ClashLuke's full-sized avatar

Lucas Nestler ClashLuke

View GitHub Profile
@ClashLuke
ClashLuke / soap.py
Created November 5, 2024 12:04
SOAP Toy problem (identity)
import torch
import torch.nn as nn
import torch.optim as optim
from itertools import chain
# Parts of the code are modifications of Pytorch's AdamW optimizer
# Parts of the code are modifications of code from https://github.com/jiaweizzhao/GaLore/blob/master/galore_torch/galore_projector.py
probe () {
ffprobe -v error -show_entries $1 -of default=noprint_wrappers=1:nokey=1 $2
}
get_bitrate (){
original=$1
filesize=$2
max_audio_bitrate=${3:-64000}
seconds=`probe format=duration $original`
total_bitrate=`echo "scale=0; (8 * $filesize/$seconds)" | bc` # filesize in byte, bitrate in bit
@ClashLuke
ClashLuke / ffmpeg_helpers.sh
Created October 16, 2022 08:09
Ideally appended to bashrc
probe () {
ffprobe -v error -show_entries $1 -of default=noprint_wrappers=1:nokey=1 $2
}
get_bitrate (){
original=$1
filesize=$2
max_audio_bitrate=${3:-64000}
seconds=`probe format=duration $original`
total_bitrate=`echo "scale=0; (8 * $filesize/$seconds)" | bc` # filesize in byte, bitrate in bit