Skip to content

Instantly share code, notes, and snippets.

Alex Shevchenko skeeet

  • Bay Area
Block or report user

Report or block skeeet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@skeeet
skeeet / .tmux.conf
Created Nov 3, 2019 — forked from paulodeleo/.tmux.conf
Tmux configuration to enable mouse scroll and mouse panel select, taken from: http://brainscraps.wikia.com/wiki/Extreme_Multitasking_with_tmux_and_PuTTY
View .tmux.conf
# Make mouse useful in copy mode
setw -g mode-mouse on
# Allow mouse to select which pane to use
set -g mouse-select-pane on
# Allow mouse dragging to resize panes
set -g mouse-resize-pane on
# Allow mouse to select windows
@skeeet
skeeet / CMakeLists.txt
Created Apr 1, 2019 — forked from zeryx/CMakeLists.txt
minimal pytorch 1.0 pytorch -> C++ full example demo image at: https://i.imgur.com/hiWRITj.jpg
View CMakeLists.txt
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(cpp_shim)
set(CMAKE_PREFIX_PATH ../libtorch)
find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
add_executable(testing main.cpp)
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
@skeeet
skeeet / danbooru_faces.md
Created Feb 20, 2019 — forked from stormraiser/danbooru_faces.md
Danbooru Faces dataset
View danbooru_faces.md

Danbooru Faces v0.1

Discription

This dataset contains ~443k anime face images of size 256x256 drawn by ~7,000 artists, obtained from Danbooru

Collection

We first downloaded JSON files of all existing posts numbered from 1 to 2,800,000 using their API. We filtered the posts by the following criteria:

@skeeet
skeeet / infinite_dataloader.py
Created Feb 20, 2019 — forked from MFreidank/infinite_dataloader.py
A pytorch DataLoader that generates an unbounded/infinite number of minibatches from the dataset.
View infinite_dataloader.py
from torch.utils.data import DataLoader
class InfiniteDataLoader(DataLoader):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Initialize an iterator over the dataset.
self.dataset_iterator = super().__iter__()
def __iter__(self):
@skeeet
skeeet / pytorch_bilinear_interpolation.md
Created Oct 6, 2018 — forked from peteflorence/pytorch_bilinear_interpolation.md
Bilinear interpolation in PyTorch, and benchmarking vs. numpy
View pytorch_bilinear_interpolation.md

Here's a simple implementation of bilinear interpolation on tensors using PyTorch.

I wrote this up since I ended up learning a lot about options for interpolation in both the numpy and PyTorch ecosystems. More generally than just interpolation, too, it's also a nice case study in how PyTorch magically can put very numpy-like code on the GPU (and by the way, do autodiff for you too).

For interpolation in PyTorch, this open issue calls for more interpolation features. There is now a nn.functional.grid_sample() feature but at least at first this didn't look like what I needed (but we'll come back to this later).

In particular I wanted to take an image, W x H x C, and sample it many times at different random locations. Note also that this is different than upsampling which exhaustively samples and also doesn't give us fle

View ycbcr-to-rgb.metal
fragment float4 capturedImageFragmentShader(ImageColorInOut in [[stage_in]],
texture2d<float, access::sample> capturedImageTextureY [[ texture(kTextureIndexY) ]],
texture2d<float, access::sample> capturedImageTextureCbCr [[ texture(kTextureIndexCbCr) ]]) {
constexpr sampler colorSampler(mip_filter::linear,
mag_filter::linear,
min_filter::linear);
const float4x4 ycbcrToRGBTransform = float4x4(
float4(+1.0000f, +1.0000f, +1.0000f, +0.0000f),
@skeeet
skeeet / std.cpp
Created Apr 19, 2018 — forked from mahuna13/std.cpp
standard library functions for Halide
View std.cpp
#include "std_try.h"
#include <math.h>
using namespace Halide;
#define PI 3.14159
/*
Interpolations
*/
@skeeet
skeeet / GeneticAlgorithm.swift
Created Apr 9, 2018 — forked from tombaranowicz/GeneticAlgorithm.swift
Simple Starter for experiments with Genetic Algorithms in Swift
View GeneticAlgorithm.swift
//: Simple Genetic Algorithm Starter in Swift 3
import UIKit
import Foundation
let AVAILABLE_GENES:[Int] = Array(1...100)
let DNA_LENGTH = 6
let TOURNAMENT_SIZE = 5
let MAX_GENERATIONS_COUNT = 100
View pytorch-conv1d-rnn.py
import torch
from torch import nn
from torch.autograd import Variable
import torch.nn.functional as F
class RNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, n_layers=1):
super(RNN, self).__init__()
self.input_size = input_size
self.hidden_size = hidden_size
@skeeet
skeeet / neural.c
Created Jan 9, 2018 — forked from hollance/neural.c
Playing with BNNS on macOS 10.12. The "hello world" of neural networks.
View neural.c
/*
The "hello world" of neural networks: a simple 3-layer feed-forward
network that implements an XOR logic gate.
The first layer is the input layer. It has two neurons a and b, which
are the two inputs to the XOR gate.
The middle layer is the hidden layer. This has two neurons h1, h2 that
will learn what it means to be an XOR gate.
You can’t perform that action at this time.