Skip to content

Instantly share code, notes, and snippets.

View eugene123tw's full-sized avatar

Eugene Liu eugene123tw

View GitHub Profile
@eugene123tw
eugene123tw / pytorch_bilinear_interpolation.md
Created June 13, 2023 21:49 — forked from peteflorence/pytorch_bilinear_interpolation.md
Bilinear interpolation in PyTorch, and benchmarking vs. numpy

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

@eugene123tw
eugene123tw / launch.json
Created May 16, 2022 13:39 — forked from beaukinstler/launch.json
vscode launch.json for python flask and pytest
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
@eugene123tw
eugene123tw / t-ortcpu.cc
Created September 9, 2021 20:06 — forked from pranavsharma/t-ortcpu.cc
onnxruntime C++ API inferencing example for CPU
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.
//
/*
pranav@XXX:~$ wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
....
2021-07-28 19:44:06 (7.60 MB/s) - ‘onnxruntime-linux-x64-1.8.1.tgz’ saved [4736207/4736207]
pranav@XXX:~$ tar xvfz onnxruntime-linux-x64-1.8.1.tgz
@eugene123tw
eugene123tw / postgres-brew.md
Last active April 5, 2020 11:18 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@eugene123tw
eugene123tw / Django EC2 Bad Request (400)
Created March 13, 2020 15:04 — forked from eezis/Django EC2 Bad Request (400)
Resolving Bad Request (400) when using Django on an EC2 instance DEBUG
This gist pertains to a Bad Request(400) error when trying to access an EC2 instance running django . . .
I set up an EC2 server, installed django, started runserver and tested. The result was
Bad Request (400)
When using Django 1.5 and higher, when DEBUG=False in the settings.py file, you must specify ALLOWED_HOSTS
or you will recieve a "Bad Request (400)" error message when attempting to retrieve a page.
On an Amazone EC2 instance, if you are testing with the public DNS, then you should put the public DNS in
@eugene123tw
eugene123tw / gitflow-breakdown.md
Created July 22, 2019 08:42 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@eugene123tw
eugene123tw / min-char-rnn.py
Created October 21, 2017 00:57 — forked from karpathy/min-char-rnn.py
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)