Skip to content

Instantly share code, notes, and snippets.

@xsa-dev
xsa-dev / hftg_demo_guanaco-33b-merged_qlora.py
Created June 17, 2023 19:36
This quanaco model for LangChain integration. Subscribe me back =)
import os
import dotenv
from langchain import HuggingFaceTextGenInference
dotenv.load_dotenv()
os.environ[
"HUGGINGFACEHUB_API_TOKEN"
] = os.getenv("HF_API_TOKEN")
@maedoc
maedoc / µrwkv.py
Last active January 24, 2024 15:09
Another short take on RWKV, towards use with time series
import numpy as np
import torch
class MyModule(torch.nn.Module):
def add_param(self, key, shape):
val = torch.randn(*shape)/np.prod(shape)
setattr(self, key, torch.nn.Parameter(val))

Risk Parity & Budgeting

With Python

Dr. Yves J. Hilpisch | The Python Quants & The AI Machine

Python for Quant Finance Meetup, London, 16. November 2022

(short link to this Gist: http://bit.ly/pqf_risk)

@rasbt
rasbt / video-subtitles-via-whisper.py
Last active September 19, 2023 21:14
Script that creates subtitles (closed captions) for all MP4 video files in your current directory
# Sebastian Raschka 09/24/2022
# Create a new conda environment and packages
# conda create -n whisper python=3.9
# conda activate whisper
# conda install mlxtend -c conda-forge
# Install ffmpeg
# macOS & homebrew
# brew install ffmpeg
# Ubuntu
@jdhao
jdhao / calculate_trainset_mean_std.py
Last active September 20, 2023 06:36
This snippet will calculate the per-channel image mean and std in the train image set. It is plain simple and may not be efficient for large scale dataset.
"""
in this script, we calculate the image per channel mean and standard
deviation in the training set, do not calculate the statistics on the
whole dataset, as per here http://cs231n.github.io/neural-networks-2/#datapre
"""
import numpy as np
from os import listdir
from os.path import join, isdir
from glob import glob
@vunb
vunb / ffmpeg-convert-mp3-to-wave
Created November 7, 2013 04:52
Convert mp3 to wave format using ffmpeg
ffmpeg -i input.mp3 -acodec pcm_s16le -ac 1 -ar 16000 output.wav
# To convert all mp3 files in a directory in Linux:
for f in *.mp3; do ffmpeg -i "$f" -acodec pcm_s16le -ac 1 -ar 16000 "${f%.mp3}.wav"; done
# Or Windows:
for /r %i in (*) do ffmpeg -i %i -acodec pcm_s16le -ac 1 -ar 16000 %i.wav
@rechargecar
rechargecar / CANTest.ino
Created November 30, 2012 19:10
MCP2515 Library example
/*
MCP2515 CAN Interface Using SPI
Author: David Harding
Created: 11/08/2010
Modified: 6/26/12 by RechargeCar Inc.
For further information see: