Skip to content

Instantly share code, notes, and snippets.

@karpathy
karpathy / gist:587454dc0146a6ae21fc
Last active May 14, 2025 00:08
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@jlisic
jlisic / rasterTool.R
Last active June 28, 2017 14:44
Simple tools to use gdal to polygonize and rasterize
library(cdlTools)
library(rgdal)
library(raster)
library(rgeos)
# rasterize in the R 'raster' package is really slow, depending on your needs this may work better
# Author: Jonathan Lisic
# License BSD
polyExtract <- function(x) {
@karpathy
karpathy / min-char-rnn.py
Last active July 10, 2025 01:16
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)
@ottokart
ottokart / nn.py
Last active August 27, 2021 05:52
3-layer neural network example with dropout in 2nd layer
# Tiny example of 3-layer nerual network with dropout in 2nd hidden layer
# Output layer is linear with L2 cost (regression model)
# Hidden layer activation is tanh
import numpy as np
n_epochs = 100
n_samples = 100
n_in = 10
n_hidden = 5
@bgusach
bgusach / multireplace.py
Last active December 10, 2024 03:51
Python string multireplacement
def multireplace(string, replacements, ignore_case=False):
"""
Given a string and a replacement map, it returns the replaced string.
:param str string: string to execute replacements on
:param dict replacements: replacement dictionary {value to find: value to replace}
:param bool ignore_case: whether the match should be case insensitive
:rtype: str
"""
@dalejbarr
dalejbarr / L3_stats_homework_5_2016.R
Created November 4, 2016 12:26
script for video walkthrough on using R/RStudio for 3-way ANOVA
## youtube video: https://youtu.be/AJDo9gpkEcg
library("readr")
library("ggplot2")
## read.csv() <- from base R. DON'T USE!
hw5 <- read_csv("homework_5.csv") # from readr
hw5$A <- factor(hw5$A)
hw5$B <- factor(hw5$B)
hw5$C <- factor(hw5$C)
@0xjac
0xjac / private_fork.md
Last active July 12, 2025 17:12
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@Arkoniak
Arkoniak / mxnet_loss_linear.jl
Last active January 17, 2017 11:47
Custom loss function in Julia MXNet, linear regression
using MXNet
import MXNet.mx: _update_single_output, reset!, get
using Distributions
#####################################
# Custom evaluation metric
# It just summarize predictions, because in the case of custom
# loss layer, ANN output equals to loss function itself
@wookietreiber
wookietreiber / README.md
Last active December 20, 2022 14:00
R - Command Line Interface (CLI) and RStudio - template

R - Interactive Sessions and Command Line Interface

This is a template for R projects that should work both on the command line as well as in an interactive session.

Template Files

The template is made up of three files:

  1. foo.r
@acmiyaguchi
acmiyaguchi / faster-rcnn-caffe-master.md
Last active March 16, 2020 14:58
py-faster-rcnn on Ubuntu 17.10 and Cuda 9.0