This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square_iterator(x: int, y: int): | |
"""Generate all the points on a square 2d lattice, spiraling out from the center. Modified from a solution by Nikita Rybak. https://stackoverflow.com/a/3706260""" | |
dx = 1 | |
dy = 0 | |
segment_length = 1 | |
leg_iterations = 0 | |
while True: | |
x += dx | |
y += dy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import sys | |
import numpy | |
import torch | |
from scipy.cluster.vq import kmeans, kmeans2 | |
from transformers import AutoTokenizer, GPT2Model | |
def magnitude(x): | |
return numpy.dot(x, x)**0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod ml_thread; | |
use gdnative::prelude::{godot_print, methods, Method, NativeClass, Node as GDNode, InitHandle, godot_init}; | |
use ml_thread::start_language_model_thread; | |
use std::sync::mpsc::{channel, Receiver, RecvError, Sender, SendError}; | |
const MAX_INPUT_LENGTH: usize = 512; | |
const BATCH_SIZE: usize = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind: | |
def __init__(self): | |
self.parents = dict() | |
def add(self, node_id:int): | |
self.parents[node_id] = node_id | |
def union(self, node_a:int, node_b:int): | |
min_parent = min(self.parents[node_a], self.parents[node_b]) | |
self.parents[node_a] = min_parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <BleKeyboard.h> | |
#include <TinyPICO.h> | |
TinyPICO tinypico = TinyPICO(); | |
BleKeyboard keyboard; // keyboard("Name", "manufacturer", battery_level_100) | |
// a .- | |
// b -... | |
// c -.-. | |
// d -.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample Usage: | |
# var day_features = [ | |
# # freezing, raining, foggy, sunny | |
# [0, 1, 0, 0], | |
# [0, 0, 0, 1], | |
# [0, 0, 0, 0], | |
# [0, 0, 1, 0], | |
# [1, 0, 0, 1], | |
# [1, 1, 0, 0], | |
# [1, 0, 1, 0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//use serde::{Serialize, Deserialize}; | |
use std::collections::HashMap; | |
// If you have serde, serialization is available with this derive chain: | |
//#[derive(Clone, Debug, Default, Serialize, Deserialize)] | |
#[derive(Clone, Debug, Default)] | |
pub struct DecisionTree { | |
feature: usize, | |
threshold: f32, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import random | |
class Graph: | |
def __init__(self): | |
self.nodes = list() | |
self.last_tape = None | |
def forward(self, variables, output_node): | |
for n in self.nodes: | |
n.forward(variables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(exports) { | |
if (!this.JSON) { | |
this.JSON = {}; | |
} | |
(function() { | |
"use strict"; | |
function f(n) { | |
return n < 10 ? "0" + n : n; | |
} | |
if (typeof Date.prototype.toJSON !== "function") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from pathlib import Path | |
import sys | |
import torch | |
from torch import nn | |
import torchvision | |
from torchvision import datasets | |
from torchvision import transforms |
NewerOlder