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)
/* | |
MCP2515 CAN Interface Using SPI | |
Author: David Harding | |
Created: 11/08/2010 | |
Modified: 6/26/12 by RechargeCar Inc. | |
For further information see: | |
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 |
""" | |
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 |
# 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 |
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)
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)) |
import os | |
import dotenv | |
from langchain import HuggingFaceTextGenInference | |
dotenv.load_dotenv() | |
os.environ[ | |
"HUGGINGFACEHUB_API_TOKEN" | |
] = os.getenv("HF_API_TOKEN") |