Skip to content

Instantly share code, notes, and snippets.

@Mr4k
Mr4k / differentialdithering.ipynb
Created Sep 9, 2020
DifferentialDithering.ipynb
View differentialdithering.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Mr4k
Mr4k / artclasswithleibnitz.ipynb
Last active Jan 17, 2021
ArtClassWithLeibnitz.ipynb
View artclasswithleibnitz.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View loss-grad-pseudocode.py
loss_grad = grad(loss)
loss_grad(circles) # this gives us the gradient with respect to the circles
View loss-pseudocode.py
def loss(circles):
return ((render(circles) - target) ** 2).sum()
@Mr4k
Mr4k / main.rs
Created Jan 6, 2020
Toy Lisp Interpreter
View main.rs
use std::env;
const EMPTY_NODE_ID: usize = 0;
// an intermediate representation for symbol data during the parse step
#[derive(Clone, Debug, PartialEq)]
struct ParseSymbol {
string: String,
debug_program_position: usize,
}
View speedtest.py
import numpy as np
from bintrees import FastAVLTree as AVLTree
import random
import time
def weightedRandom(weights):
"""
Draw from a general discrete distribution.
:param weights: A dictionary of weights that must sum to one.
:return: A random sample from it the distribution defined by the weights.
@Mr4k
Mr4k / q_learning.py
Created Apr 23, 2016
Learning Tic Tac Toe
View q_learning.py
import random
class QLearner:
def __init__(self, num_actions):
#play around with these parameters for different results
self.learning_rate = 0.03
self.discount_factor = 0.65
self.num_actions = num_actions
self.last_state = None
self.last_action = None