Skip to content

Instantly share code, notes, and snippets.

View guillefix's full-sized avatar

Guillermo Valle guillefix

View GitHub Profile
[RequireComponent(typeof(AudioSource))]
public class OpusPlayer : MonoBehaviour
{
private UDPReceiver receiver;
private AudioSource audioSource;
public int sampleRate = 48000;
public int channels = 2;
public int frameSize = 960;
public int bufferLengthInSeconds = 2;

One of the most fundamental objects in machine learning are probabilsitic models, and one of the most fundamental questions are how do make such models (i.e. how do you represent probability distributions?) and how do you train them.

Intro to deep generative models

A general solution: autoregressive models

The success of language models like GPT-3 stems in big part from the idea of representing probability distributions autoregressively, which allows computing the exact probability of a sequence/sentence, by decomposing it as a product of conditional probabilities over a tractably small number of elements (the tokens).

$P(\mathbf{x}) = P(\mathbf{x}_0) P(\mathbf{x}_1|\mathbf{x}_0)P(\mathbf{x}_2|\mathbf{x}_0, \mathbf{x}_1) ... P(\mathbf{x}_N|\mathbf{x}0,...,\mathbf{x}{N-1})$

import sys
import os
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = os.path.abspath(os.path.join(THIS_DIR, os.pardir))
sys.path.append(ROOT_DIR)
sys.path.append(THIS_DIR)
import torch
import torch.nn as nn
import torch.nn.functional as F
import uuid
import torch
from torch import nn
from .transformer import BasicTransformerModel
from models import BaseModel
from .util.generation import autoregressive_generation_multimodal
class TransformerModel(BaseModel):
def __init__(self, opt):
super().__init__(opt)
opt=self.opt
@guillefix
guillefix / neosjs-sandbox.js
Created February 19, 2021 23:39
just experimenting with requesting public records using Neos.js and stuff
const Neos = require('@bombitmanbomb/neosjs')
const neos = new Neos()
neos.on("login",(obj)=>{
// console.log(obj.Options) // Log the current user and Session
// console.log(obj.CurrentUser, obj.CurrentSession) // Log the current user and Session
})
neos.on("friendAdded",(friend)=>{
if (friend.FriendStatus == "Requested") {
neos.AddFriend(friend) // Accept the Friend Request
@guillefix
guillefix / osc-to-websocket.py
Last active September 9, 2020 04:39
simple example of redirecting OSC data to websocket
import asyncio
import websockets
import nest_asyncio
nest_asyncio.apply()
import pythonosc
from pythonosc import osc_server
from pythonosc.osc_server import AsyncIOOSCUDPServer
#ip and address of machine to host OSC and websocket servers.
ip = "192.168.50.172"
@guillefix
guillefix / server.py
Created August 25, 2020 22:10
bare python server
from http.server import BaseHTTPRequestHandler, HTTPServer
import re
import json
import numpy as np
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
@guillefix
guillefix / plots.py
Created March 3, 2020 23:27
some useful plots for generalization error / complexity data using plotly
import plotly.plotly as py
from plotly.graph_objs import *
def nice_2dhist(x,y,nbins,title='title',xlabel='x',ylabel='y',filename='nice-hist.png'):
py.sign_in(username='guillefix', api_key='mflFpFhvUHtAfpGXbKkv')
trace1 = {
"x": x,
"y": y,
"marker": {
@guillefix
guillefix / setitup.sh
Last active February 28, 2020 00:20
setup thing for nn-pacbayes
sudo apt-get update
sudo apt-get install libcr-dev mpich
#apt install python3-pip
#pip3 install tensorflow
pip3 install mpi4py pandas torch torchvision GPy matplotlib tensorflow_probability==0.7 keras
sudo apt-get install htop
#then edit the GPy file. should send them a pull request..
@guillefix
guillefix / get_furs.py
Last active February 27, 2020 02:36
scrape621
import os
import sys
import pandas as pd
if not os.path.exists("floofs"):
os.mkdir("floofs")
d = pd.read_csv("e621_"+sys.argv[1]+".csv")
d=d[d["rating"]=="s"]
import urllib.request