Skip to content

Instantly share code, notes, and snippets.

View moskomule's full-sized avatar
🎯
Focusing

Ryuichiro Hataya moskomule

🎯
Focusing
View GitHub Profile
@moskomule
moskomule / README.md
Created April 21, 2020 11:45 — forked from sevko/README.md
simple Python raytracer

raytracer

A simple Python raytracer that supports spheres with configurable "material" properties (base color and a bunch of light coefficients). To generate a raytraced image of the pre-defined scene, run: python raytracer.py and open image.ppm with a PPM-compatible viewer (eog works fine on Linux):

raytraced spheres

acknowledgements

I found the following resources extremely helpful:

@moskomule
moskomule / image_folder_tar.py
Created July 26, 2019 04:30 — forked from rwightman/image_folder_tar.py
PyTorch ImageFolder style dataset for reading directly from tarfile
import torch.utils.data as data
import os
import re
import torch
import tarfile
from PIL import Image
IMG_EXTENSIONS = ['.png', '.jpg', '.jpeg']
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@moskomule
moskomule / Rop.py
Created September 18, 2018 08:41 — forked from apaszke/Rop.py
def Rop(y, x, v):
"""Computes an Rop.
Arguments:
y (Variable): output of differentiated function
x (Variable): differentiated input
v (Variable): vector to be multiplied with Jacobian from the right
"""
w = torch.ones_like(y, requires_grad=True)
return torch.autograd.grad(torch.autograd.grad(y, x, w), w, v)