Skip to content

Instantly share code, notes, and snippets.

@YoongiKim
YoongiKim / prime_number_ml.py
Created December 24, 2018 15:35
Prime Number Theorem Approximation PyTorch
import math
import torch
from torch.autograd import Variable
import matplotlib.pyplot as plt
import numpy as np
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def num_division(value):
count = 0
@digoreis
digoreis / script-stackoverflow-database.gif
Last active March 9, 2022 19:03
Sample of parse Posts.xml of Stackoverflow
script-stackoverflow-database.gif
@claymcleod
claymcleod / pycurses.py
Last active June 27, 2024 00:17
Python curses example
import sys,os
import curses
def draw_menu(stdscr):
k = 0
cursor_x = 0
cursor_y = 0
# Clear and refresh the screen for a blank canvas
stdscr.clear()
@karpathy
karpathy / min-char-rnn.py
Last active June 28, 2024 06:13
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@Newmu
Newmu / adam.py
Last active August 11, 2019 22:24
Adam Optimizer
"""
The MIT License (MIT)
Copyright (c) 2015 Alec Radford
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@joates
joates / index.js
Created September 16, 2013 18:56
linspace(a, b, n) from Numeric Javascript by Sébastien Loisel (https://github.com/sloisel/numeric/blob/master/src/numeric.js#L922)
numeric.linspace = function linspace(a,b,n) {
if(typeof n === "undefined") n = Math.max(Math.round(b-a)+1,1);
if(n<2) { return n===1?[a]:[]; }
var i,ret = Array(n);
n--;
for(i=n;i>=0;i--) { ret[i] = (i*b+(n-i)*a)/n; }
return ret;
}
@mblondel
mblondel / svm.py
Last active April 21, 2024 13:41
Support Vector Machines
# Mathieu Blondel, September 2010
# License: BSD 3 clause
import numpy as np
from numpy import linalg
import cvxopt
import cvxopt.solvers
def linear_kernel(x1, x2):
return np.dot(x1, x2)